Skip to content

Instantly share code, notes, and snippets.

@CasperCL
Last active October 14, 2020 17:51
Show Gist options
  • Save CasperCL/5b29aeb04b943f898e01345b91a25c4e to your computer and use it in GitHub Desktop.
Save CasperCL/5b29aeb04b943f898e01345b91a25c4e to your computer and use it in GitHub Desktop.
Docker for Pyramid

Docker for Pyramid

Three files are required to dockerize your Pyramid application. Copy & paste the contents to your project directory and run with docker-compose up After this command your webserver will be up and running server on the name firehose.dev port 8080.

Stack:

version: '3'
services:
webserver:
image: nginx:latest
ports:
- "8080:80"
volumes:
- "./site.conf:/etc/nginx/conf.d/site.conf"
links:
- backend
backend:
build:
context: .
dockerfile: Pyramid.Dockerfile
image: firehose/backend:latest
volumes:
- "./development.ini:/conf/settings.ini"
# development only
- "./:/app"
# development only
entrypoint:
- gunicorn
- --paster
- /conf/settings.ini
- -b
- 0.0.0.0:8000
- --reload
server {
listen 80;
server_name firehose.dev;
access_log /var/log/nginx/firehose.log;
location / {
proxy_pass http://backend:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
FROM python:3.6-alpine
RUN pip install gunicorn
COPY . /app
WORKDIR /app
RUN python setup.py develop
VOLUME ['/conf']
RUN adduser -H -D monty
USER monty
CMD ["gunicorn", "--paster", "/conf/settings.ini", "-b", "0.0.0.0:8000"]
@CasperCL
Copy link
Author

If you don't have an .egg file in your root directory gunicorn will throw an error:

    pkg_resources.DistributionNotFound: The 'firehose' distribution was not found and is required by the application

It is advised to run python setup.py develop with an auxiliary python 3.6 environment before running docker-compose up as workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment