0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker + Django + Reactの環境構築

Posted at

Dockerfile(Django用)

FROM python:3.9.0
ENV PYTHONUNBUFFERED 1
RUN mkdir /backend
WORKDIR /backend
ADD requirements.txt /backend/
RUN pip install -r requirements.txt
ADD . /backend/

Dockerfile-nodejs(React用)

FROM node:12.19.0
RUN mkdir /frontend
WORKDIR /frontend
RUN npm install -g create-react-app

requirements.txt

Django==3.1
psycopg2

docker-compose.yml

version: '3'

services:
  db:
    image: postgres
    environment: 
      POSTGRES_PASSWORD: password
  django:
    build: .
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
      - ./backend:/backend
    ports:
      - "8000:8000"
    depends_on:
      - db

  react:
    build:
      context: .
      dockerfile: "./Dockerfile-nodejs"
    volumes:
      - .:/frontend
    command: >
        cd frontend && yarn start
    ports:
      - "3000:3000"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?