-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add dev-containers and their environment #33
base: main
Are you sure you want to change the base?
Changes from 7 commits
dfbf77b
7ced3c5
36b4ecc
bb24128
e419fe8
c60682d
781493f
d07bf58
49e561b
8332efb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
DATABASE_URL=postgresql://dev:dev@db:5432/dev | ||
DATABASE_URL=postgresql://dev:dev@postgres:5432/dev | ||
LOG_LEVEL=DEBUG | ||
SERVER_URL=example.com | ||
ACCESS_TOKEN_EXPIRE_MINUTES=15 | ||
JWT_SIGNING_KEY= | ||
JWT_SIGNING_KEY= | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.13-slim | ||
|
||
RUN apt-get update && apt-get install -y curl libpq-dev gcc git | ||
|
||
ENV POETRY_HOME="/usr/local" \ | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_CREATE=false \ | ||
POETRY_VERSION=1.8.3 | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
alias format='scripts/format.sh' | ||
alias makemigrations='scripts/makemigrations.sh' | ||
alias migrate='scripts/migrate.sh' | ||
alias shell='python src/helpers/shell.py' | ||
alias test='pytest src' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/bash | ||
|
||
|
||
# Run start commads such as poetry install to keep dependecies updates and in sync with your lock file. | ||
|
||
set -xeo pipefail | ||
|
||
poetry install --no-ansi --no-root |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
"name": "Python Template", | ||||||||||||||||||||||||||||||
"dockerComposeFile": "docker-compose.yaml", | ||||||||||||||||||||||||||||||
"service": "devcontainer", | ||||||||||||||||||||||||||||||
"runServices": [ | ||||||||||||||||||||||||||||||
"devcontainer", | ||||||||||||||||||||||||||||||
"postgres" | ||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||
"workspaceFolder": "/workspace", | ||||||||||||||||||||||||||||||
"containerEnv": { | ||||||||||||||||||||||||||||||
"PYTHONPATH": "/workspace", | ||||||||||||||||||||||||||||||
"USER": "${localEnv:USER}" | ||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||
"customizations": { | ||||||||||||||||||||||||||||||
"vscode": { | ||||||||||||||||||||||||||||||
"extensions": [ | ||||||||||||||||||||||||||||||
"ms-azuretools.vscode-docker", | ||||||||||||||||||||||||||||||
"ms-python.black-formatter", | ||||||||||||||||||||||||||||||
"ms-python.flake8", | ||||||||||||||||||||||||||||||
"ms-python.isort", | ||||||||||||||||||||||||||||||
"ms-python.python", | ||||||||||||||||||||||||||||||
"ms-python.mypy-type-checker" | ||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||
"settings": { | ||||||||||||||||||||||||||||||
"editor.formatOnSave": true, | ||||||||||||||||||||||||||||||
"editor.rulers": [ | ||||||||||||||||||||||||||||||
120 | ||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||
"editor.tabSize": 4, | ||||||||||||||||||||||||||||||
"files.insertFinalNewline": true, | ||||||||||||||||||||||||||||||
"files.trimFinalNewlines": true, | ||||||||||||||||||||||||||||||
"files.trimTrailingWhitespace": true, | ||||||||||||||||||||||||||||||
"editor.codeActionsOnSave": { | ||||||||||||||||||||||||||||||
"source.organizeImports": "explicit" | ||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||
"python.editor.defaultFormatter": "ms-python.black-formatter" | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||
"black-formatter.args": [ | ||||||||||||||||||||||||||||||
"--line-length=120" | ||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||
"unwantedRecommendations": [] | ||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||
"postCreateCommand": "cat /workspace/.devcontainer/aliases-devcontainer >> ~/.bashrc", | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||||||||||||||||||||||||||||||
"postStartCommand": "/workspace/.devcontainer/devcontainer-start.sh", | ||||||||||||||||||||||||||||||
"forwardPorts": [ | ||||||||||||||||||||||||||||||
// Backend API: | ||||||||||||||||||||||||||||||
// localhost:8000 | ||||||||||||||||||||||||||||||
"devcontainer:8000", | ||||||||||||||||||||||||||||||
// Postgres: | ||||||||||||||||||||||||||||||
// localhost:5432 for accessing postgres via local dbeaver/psql client | ||||||||||||||||||||||||||||||
"postgres:5432" | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||
"portsAttributes": { | ||||||||||||||||||||||||||||||
"5432": { | ||||||||||||||||||||||||||||||
"label": "Postgres", | ||||||||||||||||||||||||||||||
"onAutoForward": "notify" | ||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||
"8000": { | ||||||||||||||||||||||||||||||
"label": "Backend API", | ||||||||||||||||||||||||||||||
"onAutoForward": "notify" | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
services: | ||
devcontainer: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you think about include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the env vars using the property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest defining it here as more people will know where to look for it. Also one question, is env variables interpolation available if you define it in the json file? That may be another reason for having it in an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
command: sleep infinity | ||
build: . | ||
ports: | ||
- '8000:8000' | ||
volumes: | ||
- source: .. | ||
target: /workspace | ||
type: bind | ||
jrg091 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- source: cache | ||
target: /root/.cache | ||
type: volume | ||
env_file: .env | ||
|
||
postgres: | ||
image: postgres:16 | ||
pull_policy: always | ||
restart: unless-stopped | ||
environment: | ||
POSTGRES_USER: dev | ||
POSTGRES_DB: dev | ||
POSTGRES_PASSWORD: dev | ||
volumes: | ||
- source: postgres | ||
target: /var/lib/postgresql/data | ||
type: volume | ||
|
||
volumes: | ||
postgres: {} | ||
cache: {} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn´t we include the .dockerignore file in the .devcontainer file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the context of devcontainers, I'm not sure if it's worth it because we're mounting the entire repo as a volume, and we're not doing any COPY or anything similar. Maybe when we add other Dockerfiles it will be worth it, but I'm not sure if I explained myself well or what do you think? |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.