Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: devcontainer setup #126

Merged
merged 11 commits into from
Aug 17, 2022
26 changes: 13 additions & 13 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM eligibility_server:latest

# install python tooling
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt

# 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
FROM eligibility_server:latest
# install python tooling
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt
# 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
26 changes: 14 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json
{
"name": "cal-itp/eligibility-server",
"dockerComposeFile": ["compose.yml"],
"dockerComposeFile": ["../compose.yml"],
"service": "dev",
"runServices": ["dev", "docs"],
"workspaceFolder": "/home/calitp/app",
"postAttachCommand": ["/bin/bash", ".devcontainer/pre-commit.sh"],
"postStartCommand": ["/bin/bash", "bin/init.sh"],
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"batisteo.vscode-django",
"ms-python.python",
"ms-python.vscode-pylance",
"eamodio.gitlens",
"mhutchie.git-graph"
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
5 changes: 1 addition & 4 deletions .devcontainer/pre-commit.sh → .devcontainer/postAttach.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env bash
set -eu
set -eux

# initialize hook environments
pre-commit install --install-hooks --overwrite

# manage commit-msg hooks
pre-commit install --hook-type commit-msg
1 change: 1 addition & 0 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
black
flake8
pre-commit
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git/
.github/
.vscode/
.flake8
.*ignore
File renamed without changes.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run pytests

on:
pull_request:
branches: [ "*" ]
branches: ["*"]

jobs:
tests:
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Load environment variables
uses: cardinalby/export-env-action@v1
with:
envFile: .devcontainer/.env.sample
envFile: .env.sample

- name: Test with pytest
run: |
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
default_install_hook_types:
- pre-commit
- commit-msg

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.0.0
Expand Down
21 changes: 15 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.languageServer": "Pylance",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.testing.pytestEnabled": true
}
6 changes: 6 additions & 0 deletions bin/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! usr/bin/env bash
set -eux

# run database migrations

python setup.py
6 changes: 5 additions & 1 deletion bin/start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#! usr/bin/env bash
set -eux

python setup.py
# initialize Flask

bin/init.sh

# start the web server

flask run -h 0.0.0.0
13 changes: 8 additions & 5 deletions .devcontainer/compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
name: eligibility-server
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: ..
context: .
dockerfile: .devcontainer/Dockerfile
entrypoint: sleep infinity
env_file: .env
image: eligibility_server:dev
ports:
- "5000"
volumes:
- ../:/home/calitp/app/
- .:/home/calitp/app/

docs:
image: eligibility_server:dev
entrypoint: mkdocs
command: serve --dev-addr "0.0.0.0:8000"
ports:
- "8000"
volumes:
- ../:/home/calitp/app:cached
- .:/home/calitp/app