IA-4811 Create optimized Dockerfile for production#2832
IA-4811 Create optimized Dockerfile for production#2832
Conversation
| options: | ||
| max-size: '5k' | ||
| command: start_dev | ||
| image: blsq/iaso:${IMAGE_TAG:-latest} |
There was a problem hiding this comment.
You should revert all the changes in this file, so that it can still be used for local development
| @@ -1,4 +0,0 @@ | |||
| option_settings: | |||
There was a problem hiding this comment.
As long as we keep this PR open, we can leave these files deleted. But once we merge, we need to make sure that all environments have switched to docker (or at least staging ones) because removing these EBS files will break deployments
There was a problem hiding this comment.
Yeah, it's kinda what @oschvr has done so far, but not exactly
|
If you're migrating to Docker, and you get this error:
This one means that the django.config from .ebextensions already created the static files config, so we need to remove it from the environment. Run this command to remove it: |
| ENKETO_DEV: ${ENKETO_DEV:-false} | ||
| ENKETO_SIGNING_SECRET: ${ENKETO_SIGNING_SECRET} | ||
| ENKETO_URL: ${ENKETO_URL} | ||
| FAVICON_PATH: ${FAVICON_PATH} |
There was a problem hiding this comment.
When you check env vars on the server, you see that they are all blank
This is probably the reason why we don't have a favicon or an app title and so on:
- the env var value is not set in terraform (because we're fine with the default from django settings)
- docker compose turns this non-set var into a blank string, because we're explicitly passing it here
- django settings notice that there's a env var and use it instead of using the default value
We've had the same issue on console. We fixed it by calling a custom method in settings that filters out blank strings. There might be a better way though. Let's discuss this together when you're available!

What problem is this PR solving?
Bundling all build steps for frontend and backend in one single, multistage, non-root Dockerfile meant to run for prod
Related JIRA tickets
IA-4811
Changes
How to test
run
docker build -t iaso:test .and thendocker image ls, you should see the docker container built and the size (content size)Once you build it you can follow these instructions to spin up locally:
In the new docker-compose.yml file (meant for prod use), you have to make sure to populate the env vars, either through a .env or in your environment itself.
You will need a way to spin up a postgres:postgis instance and pass the connection details as env vars too.
Print screen / video
Notes
Things that the reviewers should know:
The
npmbuilderstepRUN npm run webpack-prodis very memory intensive, so if you're planning to build locally, make sure of the following:Doc
Docker Compose
You will need to populate at least these environment variables with your own values in a
.envfile:Docker Compose automatically reads a
.envfile in the project root, so nosourcecommand is needed.Alternatively, you can uncomment the
env_file:section indocker-compose.prod.ymlto pass the variables directly to the container.Note: for production deployments you need an external PostgreSQL database. The
dbservice in the compose file is only intended for local development. Make sure yourRDS_*variables point to your production database.Proceed to run docker compose on your server:
This will pull the necessary containers (iaso & nginx) and spin up the service at port 80.