volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Optimizely 12 Containerized for Linux

Hi, 

Some background: My client wants a test deployment of Optimizely 12 in their onprem Kubernetes Cluster. Not being experienced with either Optimizely/Episerver, SQL, or Docker/Kubernetes I am wondering if someone could give me a push/guide me in the right direction. 


I have successfully been able to build the solution Foundation Net Core connecting it to a local sqlexpress database. I have also tried following this guide Working with docker and containers - .NET 5 Series, Part 3 written by Mark Hall, but I am not able to get it working on my Windows developer machine with WSL2. Either way I have created an image of the project "Foundation Net Core" which can be found here: https://hub.docker.com/repository/docker/snorrejablonski/optimizelydotnetcore

At this stage I am even unsure which questions I should ask, but to start I will list some questions that I hope might have an answer or at least get me a bit further:

  1. How do i "connect" an Optimizely 12 deployment like the one I have created an image of to an existing database inside a Kubernetes cluster? 
    1. Are there any limitations to which types of databases Optimizely can connect to?
    2. Are there any other variables than the connection string in "appsettings.json" I need to modify?
  2. In the repo at Github the procedure for getting Optimizely 12 up and running is to run the setup.cmd as it is with this setup-file that the sql-server++ is defined. Is this something that should be put into the Dockerfile?

And also, if my questions are wrong and you think I should ask other ones, please indulge me and help me out! All help is greatly appreciated 😄

#268115
Dec 09, 2021 15:30

I'll have to look more closely at your questions when I have more time, but as a starting point I've got an in-progress (but largely working) Docker version of foundation-mvc-cms here: https://github.com/daniel-isaacs/foundation-mvc-cms/tree/net5-docker

I started from the blog post you linked, but made a few changes. It also includes an nginx reverse proxy in front.

Notes/short version of what’s going on via the Docker setup, roughly broken out by what each file’s doing:

  • .env
    • Defines some variables for the setup, used by the other files
  • docker-compose.yml
    • We’re bringing up three separate containers, one for the site (foundation-web), one for the database (foundation-db), one for nginx (foundation-nginx) – this sets some properties for bringing them up.
  • docker/Sql.Dockerfile
    • This defines how the database container should be built. There isn’t much to this one, except that it includes running a script (docker/build-script/SetupDatabases.sh) that creates the DB and users – that script is part of the original setup.cmd, rewritten in bash.
  • docker/Web.Dockerfile
    • This defines how the web container should be built – it covers a bunch of the other stuff from the setup.cmd, including:
      • Restoring the nuget packages
      • Running the npm build scripts
      • Building the web app (dotnet build…)
      • Publishing the web app (dotnet publish….)
    • It finishes by running a script (docker/build-script/wait_sqlserver_start_and_attachdb.sh) that waits for the database to come up (hardcoded 2 minute wait), and then launches the web app.

In theory, the steps to bring it up should be:

  1. Clone the repo:
    git clone https://github.com/daniel-isaacs/foundation-mvc-cms.git
  2. Change to the correct branch:
    git checkout net5-docker
  3. In Powershell or WSL (I’ve been using Ubuntu for my testing), go to /src/Foundation and build the Docker image (it may take a little while):
    docker-compose build
  4. Once it’s built, start the containers:
    docker-compose up -d
  5. It’ll take at least 2 minutes for it to come up (there’s a 2 minute delay built in so the DB has time to do its thing). To check if it should be ready, run the following command – if it’s ready, it should output the connection string and the port (and if it’s not ready yet, the output should just be blank):
    docker logs foundation-web
  6. Once it’s ready, try to load the site: http://localhost:4000
  7. When you’re done, you can spin it down with:
    docker-compose stop

 Once it's up, login is admin@example.com / Episerver123!

#268434
Edited, Dec 15, 2021 19:10

Thank you so much for this thourough response! I have now gotten it to work on Docker, and my current challenge is getting the "translation" from docker-compose to a Kubernetes deployment, service, and pvc. If you have any experience on that matter I would love to hear it!

#268565
Dec 17, 2021 9:29

Glad that first step is working!

I haven't been able to work on the Kubernetes side of things, but here is a blog post on how to set up the Optimizely CMS sample site using Kubernetes -- I haven't tried it, but it may be helpful for applying to the foundation site as well: https://dev.to/stoffe/optimizely-on-kubernetes-4k9n

#268700
Dec 20, 2021 16:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.