Skip to content

Instantly share code, notes, and snippets.

@andreburto
Created August 30, 2020 01:43
Show Gist options
  • Save andreburto/e4966e145b961de99188c3e2d17175ff to your computer and use it in GitHub Desktop.
Save andreburto/e4966e145b961de99188c3e2d17175ff to your computer and use it in GitHub Desktop.
nginx proxy for docker-compose
version: "3.7"
services:
uwsgi:
build:
context: .
dockerfile: Dockerfile.uwsgi
deploy:
restart_policy:
condition: on-failure
environment:
- DBHOST=xxx
- DBUSER=xxx
- DBPASS=xxx
- DATABASE=xxx
image: andreburto/test-uwsgi
volumes:
- type: bind
source: ./test-dock
target: /test-dock
networks:
- nginx-proxy
ports:
- 8000:8000
nginx:
image: nginx:latest
container_name: nginx
depends_on:
- uwsgi
volumes:
- type: bind
source: ./nginx/nginx.conf
target: /etc/nginx/nginx.conf
networks:
- nginx-proxy
ports:
- 80:80
networks:
nginx-proxy:
FROM python:3.7-alpine
WORKDIR /test-dock
# Install any needed packages specified in requirements.txt
RUN apk update && \
apk add --no-cache make gcc g++ libgcc libstdc++ libsodium musl libzmq zeromq-dev linux-headers python3-dev && \
pip install --upgrade pip && \
pip install requests beautifulsoup4 pymysql flask uwsgi && \
rm -Rf /tmp/* && \
rm -Rf /root/.cache/*
CMD ["uwsgi", "--http", ":8000", "--manage-script-name", "--mount", "/=test-dock:app"]
events { }
http {
server {
location /test {
proxy_pass http://uwsgi:8000;
rewrite ^(.*)$ / break;
}
location / {
return 301 /test;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment