0
1

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 1 year has passed since last update.

「動かして学ぶ!Python Django開発入門 第2版」の開発環境をDocker, VS Code Remote Developmentでつくる

Last updated at Posted at 2022-12-26

タイトルの通り、動かして学ぶ!Python Django開発入門 第2版の開発環境をDokcer, VS Code Remote Developmentで作ったのでそのメモです。

ディレクトリ構成

django_book
└── .devcontainer
    ├── Dockerfile
    ├── devcontainer.json
    ├── docker-compose.yml
    └── requirements.txt
  • django_bookは今回のプロジェクトのルートディレクトリ

Dockerfile

FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY ../ /app/
EXPOSE 8000

devcontainer.json

{
	"name": "Private Diary",
	"dockerComposeFile": "docker-compose.yml",
	"workspaceFolder": "/app",
	"service": "web",
	"extensions": [
		"ms-python.python"
	],
	"shutdownAction": "stopCompose"
}

docker-compose.yml

services:
  web:
    build: .
    tty: true
    volumes:
      - ../:/app
    depends_on:
      - db

  db:
    image: postgres:13.4
    volumes:
        - postgres_data:/var/lib/postgresql/data
    environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
        POSTGRES_DB: private_diary

  pgadmin4:
    image: dpage/pgadmin4
    ports:
        - 8888:80
    volumes:
        - pgadmin4_data:/var/lib/pgadmin
    environment:
        PGADMIN_DEFAULT_EMAIL: pgadmin@example.com
        PGADMIN_DEFAULT_PASSWORD: pgadmin
    depends_on:
      - db

volumes:
    postgres_data:
    pgadmin4_data:

requirements.txt

Django==3.2.7
djangorestframework==3.12.4
django-bootstrap5==2.1.2
django-allauth==0.45.0
django-cors-headers==3.10.0
psycopg2-binary==2.9.1
Pillow==8.3.2
selenium==3.141.0

black==22.12.0

参考

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?