Skip to content

Instantly share code, notes, and snippets.

@Kenan7
Last active June 2, 2020 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kenan7/e051aebca8d901f9f26b8a5348751eca to your computer and use it in GitHub Desktop.
Save Kenan7/e051aebca8d901f9f26b8a5348751eca to your computer and use it in GitHub Desktop.
Docker-compose, nginx Dockerfile, django Dockerfile
# docker-compose.yml
version: "3.7"
services:
postgres:
container_name: postgres
image: postgres
networks:
- main
volumes:
- pg-data:/var/lib/postgresql/data
backend: &backend
container_name: backend
build:
context: ./backend
dockerfile: Dockerfile
command: /scripts/start_prod.sh
networks:
- main
volumes:
- ./backend:/code
- django-static:/code/static
depends_on:
- postgres
env_file:
- ./.env.prod
nginx:
image: nginx:alpine
ports:
- "80:80"
depends_on:
- backend
volumes:
- ./nginx/prod/prod.conf:/etc/nginx/nginx.conf:ro
- django-static:/usr/src/app/static
networks:
- main
build:
context: .
dockerfile: nginx/prod/Dockerfile
volumes:
django-static:
pg-data:
networks:
main:
driver: bridge
# backend dockerfile
FROM python:3.8.0-alpine
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev
RUN pip install --upgrade pip
ADD requirements.txt /app/
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt -r requirements.txt
COPY scripts/start*.sh /
ADD . /app/
# nginx dockerfile
# build stage
FROM node:14.3.0-alpine3.10 as build-stage
WORKDIR /app/
COPY frontend/package.json /app/
RUN npm cache verify
RUN npm install
COPY frontend /app/
RUN npm run build
# production stage
FROM nginx:1.17.10-alpine as production-stage
COPY nginx/prod/prod.conf /etc/nginx/nginx.conf
COPY backend/static /usr/src/app/static/ ### problem yaranan yer, bu build olanda static foler yaranmamis olur
COPY --from=build-stage /app/dist /dist/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment