Hello,
I am running through a weird behaviour when deploying my Dockerfile on App platform.
I use ansible to deploy my App, I have 2 roles that perform template copy.
One is for gunicorn the other is for a settings file.
The gunicorn file is well copied, while the settings is simply not copied.
Here are some logs with some debugging session I’ve performed:
[2022-07-26 12:45:56] "cmd": [
[2022-07-26 12:45:56] "cat",
[2022-07-26 12:45:56] "/crm-pilates/settings.ini"
[2022-07-26 12:45:56] ],
...
[2022-07-26 12:45:56] "stdout_lines": [
[2022-07-26 12:45:56] "[DEFAULT]",
[2022-07-26 12:45:56] "EVENT_STORE_PATH= PATH",
[2022-07-26 12:45:56] "",
[2022-07-26 12:45:56] "[CORS]",
[2022-07-26 12:45:56] "CORS_ALLOW_ORIGINS= CORS",
[2022-07-26 12:45:56] "",
[2022-07-26 12:45:56] "[DATABASE]",
[2022-07-26 12:45:56] "DATABASE_URL= "
[2022-07-26 12:45:56] ]
There are no ansible errors at the end of the playbook run.
[2022-07-26 12:48:38] WARNING:root:Current main path /crm-pilates/crm_pilates/main.py
[2022-07-26 12:48:38] WARNING:root:Current working dir /crm-pilates
[2022-07-26 12:48:38] WARNING:root:Root dir: .dockerignore, .venv, Dockerfile, LICENSE, Makefile, README.md, crm_pilates, docker-compose.yml, local.persistent, log-config.json, poetry.lock, pyproject.toml, run.sh, scripts
[2022-07-26 12:48:38] WARNING:root:Module dir: __init__.py, __pycache__, api.py, command, domain, event, gunicorn.py, infrastructure, main.py, settings.py, web
you can see the gunicorn.py in the module dir but there are no settings.ini in the root dir where it should be.
Below are some logs from a local docker container (using the same deployment method):
WARNING:root:Current main path /crm-pilates/crm_pilates/main.py
WARNING:root:Current working dir /crm-pilates
WARNING:root:Root dir: crm_pilates, local.persistent, settings.ini, .venv, log-config.json, README.md, Makefile, pyproject.toml, scripts, docker-compose.yml, LICENSE, run.sh, poetry.lock, __pycache__, .dockerignore, Dockerfile
WARNING:root:Module dir: __init__.py, settings.py, api.py, main.py, command, event, infrastructure, domain, __pycache__, web, gunicorn.py
As you may see the settings.ini is present and the app is running fine on local docker.
Here is the ansible playbook command:
$(virtualenv_path)/bin/ansible-playbook scripts/ansible/playbook.yml --inventory scripts/ansible/deploy.yml --diff -vvvv
the settings role:
- name: copy settings
template:
src: settings.ini
dest: "{{ root_dir }}/settings.ini"
the server role (that copy gunicorn file):
- name: copy gunicorn configuration
template:
src: gunicorn.py
dest: "{{ root_dir }}/crm_pilates/gunicorn.py"
and the playbook:
- name: Configure settings
hosts: all
roles:
- role: settings
- role: display_settings
- role: print_settings
- name: Deploy
hosts:
deploy
docker-local
roles:
- role: server
I really don’t get why it is working on a local container and not on digital ocean App container.
If anyone has an idea and see what I don’t see.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
It’s possible this happens because App Platform builds your Docker image in an isolated environment. If your Ansible playbook generates or copies files only at runtime, those changes won’t persist in the final container unless they’re included in the Docker build context and copied in the Dockerfile.
I’m not completely sure without seeing how your build step runs inside App Platform, but in most cases, files created by Ansible after the image build phase aren’t included in the deployed app. You may want to generate or copy settings.ini earlier in your build process or handle it directly in the Dockerfile instead.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.