Created
July 26, 2022 08:47
-
-
Save marten-cz/d19673f805ad8c3fc27c14b31711a1bf to your computer and use it in GitHub Desktop.
Django & React docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.2' | |
services: | |
api: | |
container_name: app | |
build: | |
context: ./src | |
dockerfile: Dockerfile | |
restart: "no" | |
expose: | |
- "8000" | |
links: | |
- postgres:postgres | |
depends_on: | |
- postgres | |
labels: | |
- traefik.enable=false | |
tty: false | |
nginx: | |
container_name: nginx | |
restart: "no" | |
build: | |
context: ./ | |
dockerfile: Dockerfile.nginx | |
volumes: | |
- type: volume | |
source: mediadata | |
target: /www/static | |
read_only: true | |
depends_on: | |
- api | |
links: | |
- api:api | |
networks: | |
- internal | |
- proxy | |
labels: | |
- traefik.backend=booki-api | |
- traefik.frontend.rule=Host:api.vcap.me | |
- traefik.docker.network=proxy | |
- traefik.port=80 | |
postgres: | |
container_name: booki-postgres | |
restart: "no" | |
image: postgres:10.4-alpine | |
environment: | |
POSTGRES_USER: | |
POSTGRES_PASSWORD: | |
POSTGRES_USER: '' | |
POSTGRES_PASSWORD: '' | |
POSTGRES_DB: '' | |
expose: | |
- 5432 | |
healthcheck: | |
test: ["CMD-SHELL", "pg_isready -U postgres"] | |
interval: 30s | |
timeout: 30s | |
retries: 3 | |
ports: | |
- "5432:5432" | |
volumes: | |
- pgdata:/var/lib/postgresql/data/ | |
networks: | |
- internal | |
labels: | |
- traefik.enable=false | |
volumes: | |
pgdata: | |
mediadata: | |
networks: | |
proxy: | |
external: true | |
internal: | |
external: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node | |
WORKDIR /app/ | |
RUN yarn build | |
FROM nginx:1.11.1 | |
RUN rm /etc/nginx/conf.d/default.conf | |
ADD nginx.conf /etc/nginx/conf.d/web.conf | |
COPY --from=builder /app/build /www/static |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 80 default_server; | |
server_name _; | |
charset utf-8; | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location /static/ { | |
alias /www/static/; | |
} | |
location / { | |
proxy_pass http://api:8000; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment