1 Backend- Django,uwsgi,Nginx
2 Frontend- Vue, Nginx

1 Backend- Django,uwsgi,Nginx

Dockerfile_backend
FROM python:3.7-buster as builder

ENV PYTHONUNBUFFERED 1

WORKDIR /code

COPY /backend/requirements.lock /code
RUN pip install --upgrade pip \
  && pip install -r /code/requirements.lock


FROM python:3.7-slim-buster as runner

COPY --from=builder /usr/local/lib/python3.7/site-packages /usr/local/lib/python3.7/site-packages
COPY --from=builder /usr/local/bin/uwsgi /usr/local/bin/uwsgi


RUN apt update \
  && apt-get -y install default-libmysqlclient-dev -y wget \
  && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
  && apt install  --fix-broken ./google-chrome-stable_current_amd64.deb -y \
  && apt install -y libxml2 libglibd-2.0-0 -y libnss3 -y libxcb1 \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

RUN useradd -r -s /bin/false uwsgiusr
RUN mkdir -p code/src/logs/app_logs
RUN touch code/src/logs/server.log
RUN chown -R uwsgiusr code/src/logs

USER uwsgiusr

COPY /backend /code
COPY /backend/bin /var/task/bin/

CMD uwsgi --ini /code/deploy/uwsgi.ini

・pythonは3.7じゃないとスクレイピングでエラー動かない

nginxも作る

nginx/Dockerfile_nginx
FROM nginx:1.13

COPY /nginx/conf /etc/nginx/conf.d
COPY /nginx/uwsgi_params /etc/nginx/uwsgi_params
COPY /backend/static /static
nginx/conf/default.conf
upstream django {
    server 127.0.0.1:8001;
}

server {
    listen      80;
    server_name localhost;
    charset     utf-8;

    location / {
        uwsgi_pass  django;
        include     /etc/nginx/uwsgi_params;
        try_files $uri $uri/ /index.html;
    }

    location /static/ {
        alias /static/;
    }
}

2 Frontend- Vue, Nginx

Dockerfile_frontend
FROM node:lts-alpine as build-stage

WORKDIR /code
COPY /frontend/package*.json ./
RUN npm install \
  && apk add bash \
  && npm install --save axios@0.27.2 sweetalert2@11.4.17 vue-session@1.0.0 js-cookie@3.0.1
COPY /frontend /code
RUN npm run build

FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /code/dist /usr/share/nginx/html

COPY /frontend /code

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]


一応、ルートディレクトからDockerfileを立ち上げる時のコマンド

docker build -t backend -f Dockerfile_backend .
docker build -t frontend -f Dockerfile_frontend .
docker build -t nginx -f nginx/Dockerfile_nginx .