From 518379a1fd7f6fc67f34a654d0e52ce9737a7221 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 25 May 2022 21:39:57 +0000 Subject: [PATCH 1/3] chore(devcontainer): move Dockerfile, compose.yml, pre-commit.sh, env.sample into .devcontainer/ and rename accordingly --- .env.sample => .devcontainer/.env.sample | 0 Dockerfile.dev => .devcontainer/Dockerfile | 12 ++++++++---- docker-compose.yml => .devcontainer/compose.yml | 12 ++++++------ .../devcontainer.json | 6 +++--- {bin => .devcontainer}/pre-commit.sh | 0 5 files changed, 17 insertions(+), 13 deletions(-) rename .env.sample => .devcontainer/.env.sample (100%) rename Dockerfile.dev => .devcontainer/Dockerfile (55%) rename docker-compose.yml => .devcontainer/compose.yml (71%) rename .devcontainer.json => .devcontainer/devcontainer.json (82%) rename {bin => .devcontainer}/pre-commit.sh (100%) diff --git a/.env.sample b/.devcontainer/.env.sample similarity index 100% rename from .env.sample rename to .devcontainer/.env.sample diff --git a/Dockerfile.dev b/.devcontainer/Dockerfile similarity index 55% rename from Dockerfile.dev rename to .devcontainer/Dockerfile index 8ddeeec5..8f39ee42 100644 --- a/Dockerfile.dev +++ b/.devcontainer/Dockerfile @@ -2,14 +2,18 @@ FROM eligibility_server:latest USER root -# install tooling: curl, git, jq, ssh -# install python tooling: pip, flake8, pre-commit +# install container tooling RUN apt-get update \ && apt-get install -qq --no-install-recommends curl git jq ssh build-essential \ && python -m pip install --upgrade pip -RUN pip install --no-cache-dir flake8 pre-commit coverage pytest +# install python tooling +RUN pip install --no-cache-dir flake8 pre-commit -# install docs tooling: +# install docs tooling COPY docs/requirements.txt docs/requirements.txt RUN pip install --no-cache-dir -r docs/requirements.txt + +# install test tooling +COPY tests/requirements.txt tests/requirements.txt +RUN pip install -r tests/requirements.txt diff --git a/docker-compose.yml b/.devcontainer/compose.yml similarity index 71% rename from docker-compose.yml rename to .devcontainer/compose.yml index 28370500..c200b300 100644 --- a/docker-compose.yml +++ b/.devcontainer/compose.yml @@ -2,17 +2,17 @@ version: "3.8" services: server: - build: . + build: .. env_file: .env image: eligibility_server:latest ports: - "5000" volumes: - - ./:/home/calitp/app/ + - ../:/home/calitp/app/ dev: build: - context: . - dockerfile: Dockerfile.dev + context: .. + dockerfile: .devcontainer/Dockerfile command: sleep infinity entrypoint: [] env_file: .env @@ -20,7 +20,7 @@ services: ports: - "5000" volumes: - - ./:/home/calitp/app/ + - ../:/home/calitp/app/ docs: image: eligibility_server:dev entrypoint: mkdocs @@ -28,4 +28,4 @@ services: ports: - "8000" volumes: - - ./:/home/calitp/app:cached + - ../:/home/calitp/app:cached diff --git a/.devcontainer.json b/.devcontainer/devcontainer.json similarity index 82% rename from .devcontainer.json rename to .devcontainer/devcontainer.json index a500fdab..e06e34c2 100644 --- a/.devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,11 @@ // For format details, see https://aka.ms/vscode-remote/devcontainer.json { "name": "cal-itp/eligibility-server", - "dockerComposeFile": ["./docker-compose.yml"], + "dockerComposeFile": ["compose.yml"], "service": "dev", "runServices": ["dev", "docs"], "workspaceFolder": "/home/calitp/app", - "postAttachCommand": ["/bin/bash", "bin/pre-commit.sh"], + "postAttachCommand": ["/bin/bash", ".devcontainer/pre-commit.sh"], // Set *default* container specific settings.json values on container create. "settings": { @@ -21,6 +21,6 @@ "extensions": [ "batisteo.vscode-django", "ms-python.python", - "ms-python.vscode-pylance", + "ms-python.vscode-pylance" ] } diff --git a/bin/pre-commit.sh b/.devcontainer/pre-commit.sh similarity index 100% rename from bin/pre-commit.sh rename to .devcontainer/pre-commit.sh From 539fc735559ef10f9e400b7fb9dd6f7b0d6c931a Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 25 May 2022 21:40:19 +0000 Subject: [PATCH 2/3] docs(devcontainer): add cd .devcontainer command --- docs/README.md | 1 + docs/getting-started.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/README.md b/docs/README.md index 9f924f4c..eb090197 100644 --- a/docs/README.md +++ b/docs/README.md @@ -23,6 +23,7 @@ Running the application locally is possible with [Docker and Docker Compose](htt ### Build the Docker container for local development ```bash +cd .devcontainer docker compose build server ``` diff --git a/docs/getting-started.md b/docs/getting-started.md index db3b5df4..9f13bece 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -18,6 +18,7 @@ cd eligibility-server Use the sample as the template. ```bash +cd .devcontainer cp .env.sample .env ``` @@ -29,6 +30,7 @@ The .env file specifies two values: ### Build image using Docker Compose ```bash +cd .devcontainer docker compose build --no-cache server ``` From 3797a7549c0efcdd01a36555050d49a3e9c2ba59 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Fri, 27 May 2022 01:00:33 +0000 Subject: [PATCH 3/3] docs: add .env file command --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index eb090197..a66a2e16 100644 --- a/docs/README.md +++ b/docs/README.md @@ -24,6 +24,7 @@ Running the application locally is possible with [Docker and Docker Compose](htt ```bash cd .devcontainer +cp .env.sample .env docker compose build server ```