Skip to content

Commit

Permalink
Add .devcontainer goodness. (#19)
Browse files Browse the repository at this point in the history
* Add .devcontainer goodness.

* Fix issue.
  • Loading branch information
chrlyons authored May 15, 2024
1 parent 18a68e1 commit a37d76e
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Full Stack Development Environment",
"dockerComposeFile": "../dev-compose.yml",
"service": "dev",
"workspaceFolder": "/testworks",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python"
},
"extensions": [
"ms-python.python",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
],
"forwardPorts": [
3000,
8000
],
"containerEnv": {
"DATABASE_URL": "postgresql://testuser:testpassword@db:5432/test",
"REDIS_URL": "redis://redis:6379",
"ALGORITHM": "HS256",
"SECRET_KEY": "1<3TwoTestThings!123456789",
"REACT_APP_API_URL": "http://localhost:8000"
},
"postCreateCommand": "echo 'Environment setup complete!'",
"remoteUser": "root"
}
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.coverage
.env
report.html
test.Dockerfile
__pycache__/
node_modules/
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run FastAPI",
"type": "shell",
"command": "uvicorn",
"args": [
"backend.app.main:app",
"--reload",
"--host=0.0.0.0",
"--port=8000"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"type": "npm",
"script": "start",
"path": "frontend",
"problemMatcher": [],
"label": "npm: start - frontend",
"detail": "react-scripts start",
"group": {
"kind": "build",
"isDefault": false
}
}
]
}
1 change: 0 additions & 1 deletion pytest.ini → backend/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
markers =
unit:
integration:
e2e:
model:
schema:
generate_report_on_test = True
42 changes: 42 additions & 0 deletions dev-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.8'
services:
db:
image: postgres:16.2
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: test
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U testuser -d test" ]
interval: 10s
timeout: 5s
retries: 5

redis:
container_name: redis
image: "redis:alpine"
ports:
- "6379:6379"
volumes:
- redis_data:/data

dev:
build:
context: .
dockerfile: dev.Dockerfile
ports:
- "3000:3000"
- "8000:8000"
volumes:
- .:/testworks
command: ["sleep", "infinity"]
depends_on:
- db

volumes:
postgres_data:
redis_data:
38 changes: 38 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:22.04 AS base

# Install system dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-dev \
libpq-dev \
gcc \
nodejs \
npm \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY .vscode ./testworks/
WORKDIR /testworks/backend

RUN pip install psycopg2-binary==2.9.9 poetry==1.8.3
RUN poetry config virtualenvs.create false
COPY ./backend /testworks/backend/
RUN poetry install --no-dev --no-interaction --no-ansi
ENV PYTHONUNBUFFERED=1
EXPOSE 8000

COPY ./tests /testworks/tests
WORKDIR /testworks/tests
RUN poetry install --no-dev --no-interaction --no-ansi
RUN playwright install chromium

WORKDIR /testworks/frontend
COPY ./frontend/package*.json /testworks/frontend/
RUN npm install
COPY ./frontend /testworks/frontend
RUN npm run build
RUN npm install -g serve
EXPOSE 3000
5 changes: 5 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
markers =
integration:
e2e:
generate_report_on_test = True

0 comments on commit a37d76e

Please sign in to comment.