Skip to content

Commit 1a95988

Browse files
Ben FitzhardingeBen Fitzhardinge
authored andcommitted
new use_uv
1 parent 33a1285 commit 1a95988

33 files changed

Lines changed: 428 additions & 338 deletions

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121

2222
// Use 'postCreateCommand' to run commands after the container is created.
2323
// Note: Useful for when they open it and want everything to just start
24-
"postCreateCommand": "./.devcontainer/setup.sh"
24+
"postCreateCommand": "./.devcontainer/setup.sh",
25+
"postStartCommand": "./.devcontainer/post_start.sh"
2526
}

.devcontainer/post_start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Run the database in the background
4+
docker compose up -d

.devcontainer/setup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,16 @@ fi
2525
(cd server && uv sync)
2626
(cd client && npm install)
2727

28+
# Run the database in the background
29+
docker compose up -d
30+
31+
# Wait for the database to start
32+
# Get the container ID of the db service
33+
DB_CONTAINER_ID=$(docker compose ps -q db)
34+
echo "Waiting for the database to be ready..."
35+
until [ "$(docker inspect -f '{{.State.Health.Status}}' "$DB_CONTAINER_ID")" == "healthy" ]; do
36+
sleep 1
37+
done
38+
2839
# Nuke and migrate db
2940
(cd server && uv run ./nuke.sh)

.editorconfig

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
# python files
15+
[*.py]
16+
trim_trailing_whitespace = true
17+
18+
# config files
19+
[*.{json,json5,yaml,yml,toml}]
20+
indent_size = 2
21+
22+
# Javascript and Typescript
23+
[*.{js,jsx,ts,tsx,vue}]
24+
indent_size = 2
25+
block_comment_start = /**
26+
block_comment = *
27+
block_comment_end = */
28+
29+
# HTML and CSS
30+
[*.{htm,html,css,sass,scss,less,svg}]
31+
indent_size = 2
32+
33+
# Terraform
34+
[*.{tf,tfvars}]
35+
indent_size = 2
36+
37+
# Shell scripts
38+
[*.{sh,bat.tpl,Makefile.tpl}]
39+
indent_style = tab
40+
41+
# Makefiles
42+
[Makefile]
43+
indent_style = tab
44+
45+
# windows scripts
46+
[*.{cmd,bat}]
47+
end_of_line = crlf
48+
49+
# Markdown
50+
[*.md]
51+
trim_trailing_whitespace = false
52+
indent_style = space
53+
indent_size = 2
54+
55+
# diff files
56+
[*.diff]
57+
trim_trailing_whitespace = false

.env.prod.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ APP_NAME=DjangoAPI
88
API_SECRET_KEY= CHANGE THIS TO A RANDOM STRING
99
API_ALLOWED_HOSTS=".localhost 127.0.0.1 [::1] .codersforcauses.org"
1010

11+
POSTGRES_HOST=db
12+
POSTGRES_NAME=postgres
13+
POSTGRES_USER=postgres
14+
POSTGRES_PASSWORD=password
15+
POSTGRES_PORT=5432
16+
1117
DJANGO_SUPERUSER_PASSWORD= CHANGE THIS TO A RANDOM STRING
1218
DJANGO_SUPERUSER_EMAIL= CHANGE THIS TO A VALID EMAIL
1319
DJANGO_SUPERUSER_USERNAME= CHANGE THIS TO A VALID USERNAME

.github/workflows/ci-backend.yml

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@ on:
99

1010
jobs:
1111
lint:
12-
name: Run Flake8
12+
name: Run linting
1313
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: server
1417
steps:
15-
- uses: actions/checkout@v4
18+
- name: Checkout
19+
uses: actions/checkout@v5
1620

17-
- name: "Set up Python"
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: 3.12
21+
- name: get ruff
22+
uses: astral-sh/ruff-action@v3
2123

22-
- name: "Install flake8 and plugins"
23-
run: |
24-
pip install flake8 flake8-django
24+
- name: ruff check
25+
run: ruff check
2526

26-
- name: "Run flake8"
27-
uses: liskin/gh-problem-matcher-wrap@v1
28-
with:
29-
linters: flake8
30-
run: flake8 --max-line-length 150 server/
27+
- name: ruff format check
28+
run: ruff format --check
3129

3230
build:
3331
name: Build and test
@@ -50,18 +48,13 @@ jobs:
5048

5149
steps:
5250
- name: Checkout
53-
uses: actions/checkout@v4
54-
55-
- name: Set up Python
56-
uses: actions/setup-python@v5
57-
with:
58-
python-version: "3.12"
51+
uses: actions/checkout@v5
5952

6053
- name: Install uv
61-
run: pip install uv
54+
uses: astral-sh/setup-uv@v6
6255

6356
- name: Install dependencies 👨🏻‍💻
64-
run: uv sync --frozen
57+
run: uv sync --frozen --all-groups
6558

6659
- name: Run Migrations 🕊️
6760
env:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@ You can run `npm install` and `uv sync` in the respective `client` and `server`
158158

159159
### Changing env vars
160160

161-
Edit the `.env` file in the respective directory (client or server).
161+
Edit the `.env` file in the respective directory (client or server).

client/eslint.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import tsParser from "@typescript-eslint/parser";
66
const compat = new FlatCompat({
77
baseDirectory: import.meta.dirname,
88
})
9-
9+
1010
const eslintConfig = [
1111
...compat.config({
1212
extends: ["next/core-web-vitals", "next/typescript"]
@@ -32,5 +32,5 @@ const eslintConfig = [
3232
ignores: ["node_modules/**", ".next/**", "next-env.d.ts"]
3333
}
3434
]
35-
36-
export default eslintConfig
35+
36+
export default eslintConfig

client/next.config.mjs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
// import os from "node:os";
2-
// import isInsideContainer from "is-inside-container";
1+
import os from "node:os";
2+
import isInsideContainer from "is-inside-container";
33

4-
// const isWindowsDevContainer = () =>
5-
// os.release().toLowerCase().includes("microsoft") && isInsideContainer();
4+
const isWindowsDevContainer = () =>
5+
os.release().toLowerCase().includes("microsoft") && isInsideContainer();
66

77
/** @type {import('next').NextConfig} */
8-
9-
const config = {
8+
const nextConfig = {
109
reactStrictMode: true,
11-
turbopack: {
12-
root: import.meta.dirname,
13-
}
14-
// Turns on file change polling for the Windows Dev Container
15-
// Doesn't work currently for turbopack, so file changes will not automatically update the client.
16-
// watchOptions: isWindowsDevContainer()
17-
// ? {
18-
// pollIntervalMs: 1000
19-
// }
20-
// : undefined,
10+
// dumb fix for windows docker
11+
webpack: isWindowsDevContainer()
12+
? (config) => {
13+
config.watchOptions = {
14+
poll: 1000,
15+
aggregateTimeout: 300,
16+
};
17+
return config;
18+
}
19+
: undefined,
2120
};
2221

23-
export default config;
22+
export default nextConfig;

docker-compose.prod.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
services:
2+
db:
3+
image: postgres:16.4
4+
restart: unless-stopped
5+
volumes:
6+
- ./data/db:/var/lib/postgresql/data
7+
env_file: ./.env.prod
8+
healthcheck:
9+
test: ["CMD-SHELL", "pg_isready -U postgres"]
10+
interval: 3s
11+
timeout: 3s
12+
retries: 5
13+
214
server:
315
image: ghcr.io/codersforcauses/django-nextjs-template-use_uv-prod-server:latest
416
container_name: transplant_server
@@ -12,6 +24,8 @@ services:
1224
- ./opt/static_files:/opt/static_files
1325
environment:
1426
- DJANGO_SETTINGS_MODULE=api.settings
27+
depends_on:
28+
- db
1529

1630
client:
1731
image: ghcr.io/codersforcauses/django-nextjs-template-use_uv-prod-client:latest

0 commit comments

Comments
 (0)