Django + Next + Postgres + Docker + Nginx
| 1 | FROM alpine:3.17 |
| 2 | |
| 3 | # install node, python, postgres, and nginx |
| 4 | RUN apk add --no-cache postgresql |
| 5 | RUN apk add --no-cache nodejs |
| 6 | RUN apk add --no-cache python3 |
| 7 | RUN apk add --no-cache nginx |
| 8 | RUN apk add --no-cache py3-pip |
| 9 | RUN apk add --no-cache npm |
| 10 | |
| 11 | # configure postgres |
| 12 | RUN mkdir -p /run/postgresql |
| 13 | RUN chown -R postgres:postgres /run/postgresql |
| 14 | |
| 15 | # configure nginx |
| 16 | RUN mkdir -p /run/nginx |
| 17 | RUN chown -R nginx:nginx /run/nginx |
| 18 | |
| 19 | # install node dependencies |
| 20 | COPY ./frontend/package.json /frontend/package.json |
| 21 | WORKDIR /frontend |
| 22 | RUN npm install |
| 23 | |
| 24 | # install python dependencies |
| 25 | COPY ./backend/requirements.txt /backend/requirements.txt |
| 26 | WORKDIR /backend |
| 27 | RUN pip install -r requirements.txt |
| 28 | |
| 29 | # configure node |
| 30 | COPY ./frontend /frontend |
| 31 | WORKDIR /frontend |
| 32 | RUN npm run build |
| 33 | |
| 34 | # configure django |
| 35 | ENV IS_DOCKER=1 |
| 36 | ENV PYTHONDONTWRITEBYTECODE=1 |
| 37 | ENV PYTHONUNBUFFERED=1 |
| 38 | COPY ./backend /backend |
| 39 | |
| 40 | # copy files |
| 41 | COPY ./backend /backend |
| 42 | |
| 43 | WORKDIR / |
| 44 | COPY ./docker-entrypoint.sh / |
| 45 | |
| 46 | CMD ["sh", "docker-entrypoint.sh"] |