Docker環境にGitHubリポジトリをクローンして開発する


press
Docker環境にGitHubリポジトリをクローンして開発する

Docker環境にGitHubリポジトリをクローンして開発する

Djangoを含んで起動させるDockerプロジェクトの例はいくつか見つかりましたが、Docker環境に別で開発しているリポジトリをクローンして開発を進める方法の情報が少なかったので方法をまとめました。

コードはGitHubリポジトリにあげています。

開発環境

$ tree
.
├── Dockerfile
├── README.md
├── docker-compose.yml
├── nginx
│   ├── Dockerfile
│   └── nginx.conf
└── simple-django-project
    ├── Pipfile
    ├── Pipfile.lock
    ├── README.md
    └── config

開発環境

PC: MacBook Pro (14, 2021)
OS: macOS Monterey 12.6.7
Python: 3.11.6

$ git clone https://github.com/nobnov/simple-django-project.git

Dockerfileを編集

    ADD PROJECTNAME/Pipfile /code/
    ADD PROJECTNAME/Pipfile.lock /code/
    ↓
    ADD simple-django-project/Pipfile /code/
    ADD simple-django-project/Pipfile.lock /code/

docker-compose.ymlを編集

    web:
    ...
    command: gunicorn WSGIPATH.wsgi:application --bind 0.0.0.0:8000
    volumes:
        - ./PROJECTNAME:/code
    ↓
    command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
    volumes:
        - ./simple-django-project/config/:/code


    nginx:pw
    ...
    volumes:
            - ./PROJECTNAME/static:/static
    ↓
    volumes:
            - ./simple-django-project/config/static:/static

Dockerをビルド

$ docker-compose build

Dockerを起動

$ docker-compose up -d

コンテナ内にアクセス

$ docker-compose exec web bash

人気のタグ

Alembic API argparse Beautiful Soup black Channels charset CodeCommit datetime Django REST framework Docker enumerate f-string git GitHub glob Google Colaboratory i18n IAM Internship Jupyter Lambda Matplotlib Nginx OpenCV pandas PIL Pillow PostgreSQL PyCharm PyCon pyenv PyTorch Redis Rembg ReportLab requests S3 Sentry slack tqdm uWSGI venv Vue.js youtube


株式会社ファントムへのお問い合わせ

群馬県でPythonを使ったAIやソフトウェアを開発している株式会社ファントムが運営しています。




    Show Comments (0)

    Comments

    Related Articles

    Python

    Appleシリコン搭載MacのDocker環境でTensorflowを使う

    Appleシリコン搭載MacのDocker環境でTensorflowを使う Intel搭載のMacで作成したTensorflowを使ったプロジェクトを移して、M1やM2などのAppleシリコンを搭載しているMacでTen […]

    Posted on by press
    Django

    psycopg2がインストールできずエラーになる

    psycopg2がインストールできずエラーになる DjangoでPostgreSQLに接続するために、以下のコマンドでpsycopg2をインストールしたところ、以下のエラーが発生した時の対処法です。 エラー 実際には…の […]

    Posted on by press