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

    Django

    Vue.jsとDjango REST Frameworkで画面が真っ白になる原因〜2〜

    Vue.jsとDjango REST Frameworkで画面が真っ白になる原因〜2〜 Django REST Frameworkと組み合わせたVue.jsで、ビルド後にバックエンドの開発サーバー(8000ポートなど)で […]

    Posted on by press
    Django

    WARNING: `pyenv init -` no longer sets PATH.

    WARNING: `pyenv init -` no longer sets PATH. pyenvが入っているzsh環境(Mac)でターミナルの起動時に以下のエラーが出るようになりました。今回はDjangoのプロジェク […]

    Posted on by press