Skip to content

Commit 32ff2bc

Browse files
authored
Add tailwind & landing page (#140)
1 parent 1df5440 commit 32ff2bc

File tree

20 files changed

+1409
-60
lines changed

20 files changed

+1409
-60
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.git/
33
.venv/
44
__pycache__/
5+
dist/
56
node_modules/

.github/workflows/main.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ jobs:
2929
--exclude=.github \
3030
project_name .
3131
32-
- name: Create blank index.js file
33-
run: |
34-
mkdir -p client/dist
35-
touch client/dist/index.js
36-
3732
- name: Set up Docker Buildx
3833
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
3934

@@ -61,10 +56,10 @@ jobs:
6156
curl -I --retry 10 --retry-all-errors --fail \
6257
localhost:8000/project_name-admin/login/
6358
64-
- name: curl /static/index.js
59+
- name: curl /static/bundles/main.css
6560
run: |
6661
curl -I --retry 10 --retry-all-errors --fail \
67-
localhost:8000/static/index.js
62+
localhost:8000/static/bundles/main.css
6863
6964
- name: Check missing migrations
7065
run: docker compose exec app coverage run -m manage makemigrations --check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/staticfiles
77
/{{ project_name }}.yml
88
__pycache__
9+
dist/

.prettierrc.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
plugins = [
22
"prettier-plugin-jinja-template",
3+
"prettier-plugin-tailwindcss",
34
]
45
printWidth = 88
56
semi = true
67
singleAttributePerLine = true
78
singleQuote = false
89
tabWidth = 2
10+
tailwindStylesheet = "ui/main.css"
911
trailingComma = "all"
1012

1113
[[overrides]]

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ init: ## Initialize the project
88
command -v uvx || curl -LsSf https://astral.sh/uv/install.sh | sh \
99
&& docker compose build \
1010
&& docker compose run --rm app python manage.py migrate \
11+
&& docker compose stop \
1112
&& git init && git add . \
1213
&& command -v pre-commit || uv tool install pre-commit \
1314
&& pre-commit install

client/index.js

Whitespace-only changes.

client/package-lock.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

client/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

compose.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
---
22
services:
3-
client:
4-
build:
5-
context: .
6-
dockerfile: docker/app/Dockerfile
7-
target: build-node
8-
command: npm run dev
9-
volumes:
10-
- .:/home/node/app
11-
# node_modules is not shared with the host
12-
- /home/node/app/node_modules
13-
- client:/home/node/app/client/dist
14-
153
db:
164
image: postgres:18-alpine
175
environment:
@@ -34,6 +22,7 @@ services:
3422
restart: on-failure
3523
depends_on:
3624
- db
25+
- tailwind
3726
command: python manage.py runserver 0.0.0.0:8000
3827
ports:
3928
- ${PORT:-8000}:8000
@@ -42,7 +31,18 @@ services:
4231
volumes:
4332
- .:/app
4433
- /app/.venv
45-
- client:/app/client/dist
34+
35+
tailwind:
36+
build:
37+
context: .
38+
dockerfile: docker/app/Dockerfile
39+
target: build-node
40+
command: npm run tailwind-watch
41+
tty: true
42+
stop_grace_period: 0s
43+
volumes:
44+
- ./:/app
45+
- /app/node_modules # node_modules is not shared with the host
4646

4747
prettier:
4848
build:

docker/app/Dockerfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# STAGE 1: BUILD NODE
2-
FROM node:25.2.1-alpine AS build-node
2+
FROM node:25.2-alpine AS build-node
3+
ARG PROJECT_NAME="{{ project_name }}"
4+
5+
WORKDIR /app
6+
RUN --mount=type=bind,source=package.json,target=package.json \
7+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
8+
npm install --no-save
9+
10+
RUN --mount=type=bind,source=package.json,target=package.json \
11+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
12+
--mount=type=bind,source=ui/,target=ui/ \
13+
--mount=type=bind,source=${PROJECT_NAME},target=${PROJECT_NAME}/ \
14+
npm run tailwind-build
315

4-
WORKDIR /home/node/app/client
5-
COPY client/package-lock.json client/package.json ./
6-
RUN --mount=type=cache,target=/home/node/.npm \
7-
set -ex && npm install -g npm@latest && npm ci
8-
COPY client/ ./
9-
RUN npm run build
1016

1117

1218
# STAGE 2: BUILD PYTHON
@@ -28,7 +34,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
2834
uv sync --locked
2935

3036
COPY . ./
31-
COPY --from=build-node /home/node/app/client/dist ./client/dist
37+
COPY --from=build-node /app/dist/ /opt/static/
3238
RUN SECRET_KEY=s python manage.py collectstatic --noinput
3339

3440
EXPOSE 8000

0 commit comments

Comments
 (0)