Skip to content

Commit 0d35c6a

Browse files
committed
chore: cleanup
1 parent 1027ade commit 0d35c6a

7 files changed

Lines changed: 80 additions & 106 deletions

File tree

GEMINI.md

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

src/Litestar/Config/Makefile.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ stop-infra:
2222
docker compose -f $(INFRA_COMPOSE_FILE) down
2323
@echo "Infrastructure stopped. ✅"
2424
{% endif %}
25+
26+
{% if docker %}
27+
.PHONY: start
28+
start:
29+
@echo "Starting application with Docker... 🔄"
30+
docker compose up -d
31+
@echo "Application started. ✅"
32+
33+
.PHONY: stop
34+
stop:
35+
@echo "Stopping application with Docker... 🔄
36+
docker compose down
37+
@echo "Application stopped. ✅"
38+
{% endif %}

src/Litestar/Config/README.md.jinja

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
A Litestar application generated with [litestar-start](https://github.com/Harshal6927/litestar-start).
44

5+
{% if docker and database.value not in ['None', 'SQLite'] %}
6+
## Docker start
7+
8+
> NOTE: Ensure dev infra is stopped by `make stop-infra`
9+
10+
Create migrations:
11+
12+
```bash
13+
litestar database init
14+
litestar database make-migrations
15+
```
16+
17+
Build and run the Docker containers:
18+
19+
```bash
20+
make start
21+
```
22+
{% endif %}
23+
524
## Features
625

726
- ⚡ **Litestar** - High-performance ASGI framework

src/Litestar/Containers/Dockerfile.jinja

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.12
1+
ARG PYTHON_VERSION=3.13
22

33
# ------------------------------------------------------------------------------
44
# Base stage
@@ -10,7 +10,9 @@ RUN apt-get update \
1010
&& apt-get install -y --no-install-recommends tini \
1111
&& apt-get autoremove -y \
1212
&& apt-get clean -y \
13-
&& rm -rf /var/lib/apt/lists/* \
13+
&& rm -rf /root/.cache \
14+
&& rm -rf /var/apt/lists/* \
15+
&& rm -rf /var/cache/apt/* \
1416
&& mkdir -p /workspace/app
1517

1618
# Install uv
@@ -23,11 +25,10 @@ WORKDIR /workspace/app
2325
# ------------------------------------------------------------------------------
2426
FROM base AS builder
2527

26-
COPY pyproject.toml ./
27-
RUN uv sync --no-dev --frozen --no-install-project
28-
2928
COPY . .
3029

30+
RUN uv sync --no-dev --frozen --no-install-project
31+
3132
# ------------------------------------------------------------------------------
3233
# Runtime stage
3334
# ------------------------------------------------------------------------------
@@ -53,5 +54,8 @@ RUN addgroup --system --gid 65532 appgroup \
5354
USER appuser
5455
EXPOSE 8000
5556

56-
ENTRYPOINT ["tini", "--"]
57-
CMD ["litestar", "run", "--host", "0.0.0.0", "--port", "8000"]
57+
{% if advanced_alchemy %}
58+
CMD ["sh", "-c", "litestar database upgrade --no-prompt && exec tini -- litestar run --host 0.0.0.0 --port 8000"]
59+
{% else %}
60+
CMD ["sh", "-c", "exec tini -- litestar run --host 0.0.0.0 --port 8000"]
61+
{% endif %}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
services:
2-
{% if database.value == "PostgreSQL" %}
2+
{% if database.value == "PostgreSQL" %}
33
postgres:
44
image: postgres:17.7-alpine3.23
5-
container_name: {{ project_slug }}_postgres_db
5+
container_name: {{ project_slug }}_postgres_dev_db
66
environment:
77
POSTGRES_DB: mydb
88
POSTGRES_USER: myuser
99
POSTGRES_PASSWORD: mypassword
1010
volumes:
11-
- {{ project_slug }}_postgres_db:/var/lib/postgresql/data
11+
- {{ project_slug }}_postgres_dev_db:/var/lib/postgresql/data
1212
ports:
1313
- "5432:5432"
1414
healthcheck:
@@ -19,18 +19,18 @@ services:
1919
restart: unless-stopped
2020

2121
volumes:
22-
{{ project_slug }}_postgres_db: {}
23-
{% elif database.value == "MySQL" %}
22+
{{ project_slug }}_postgres_dev_db: {}
23+
{% elif database.value == "MySQL" %}
2424
mysql:
2525
image: mysql:8.4.8-oraclelinux9
26-
container_name: {{ project_slug }}_mysql_db
26+
container_name: {{ project_slug }}_mysql_dev_db
2727
environment:
2828
MYSQL_DATABASE: mydb
2929
MYSQL_USER: myuser
3030
MYSQL_PASSWORD: mypassword
3131
MYSQL_ROOT_PASSWORD: rootpassword
3232
volumes:
33-
- {{ project_slug }}_mysql_db:/var/lib/mysql
33+
- {{ project_slug }}_mysql_dev_db:/var/lib/mysql
3434
ports:
3535
- "3306:3306"
3636
healthcheck:
@@ -41,5 +41,5 @@ volumes:
4141
restart: unless-stopped
4242

4343
volumes:
44-
{{ project_slug }}_mysql_db: {}
45-
{% endif %}
44+
{{ project_slug }}_mysql_dev_db: {}
45+
{% endif %}

src/Litestar/Containers/docker-compose.yml.jinja

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,38 @@ services:
99
environment:
1010
- APP_ENV=production
1111
- DEBUG=false
12-
{% if has_database %}
13-
{% if database.value == "PostgreSQL" %}
12+
{% if has_database %}
13+
{% if database.value == "PostgreSQL" %}
1414
- DATABASE_URL=postgresql+psycopg://myuser:mypassword@postgres:5432/mydb
15-
{% elif database.value == "MySQL" %}
15+
{% elif database.value == "MySQL" %}
1616
- DATABASE_URL=mysql+asyncmy://myuser:mypassword@mysql:3306/mydb
17-
{% elif database.value == "SQLite" %}
17+
{% elif database.value == "SQLite" %}
1818
- DATABASE_URL=sqlite+aiosqlite:///./app.db
19-
{% endif %}
20-
{% endif %}
19+
{% endif %}
20+
{% endif %}
2121
env_file:
2222
- .env
23-
{% if database.value == "PostgreSQL" %}
23+
{% if database.value == "PostgreSQL" %}
2424
depends_on:
2525
postgres:
2626
condition: service_healthy
27-
{% elif database.value == "MySQL" %}
27+
{% elif database.value == "MySQL" %}
2828
depends_on:
2929
mysql:
3030
condition: service_healthy
31-
{% endif %}
31+
{% endif %}
3232
restart: unless-stopped
3333

34-
{% if database.value == "PostgreSQL" %}
34+
{% if database.value == "PostgreSQL" %}
3535
postgres:
36-
image: postgres:17-alpine
37-
container_name: {{ project_slug }}_postgres
36+
image: postgres:17.7-alpine3.23
37+
container_name: {{ project_slug }}_postgres_db
3838
environment:
3939
POSTGRES_DB: mydb
4040
POSTGRES_USER: myuser
4141
POSTGRES_PASSWORD: mypassword
4242
volumes:
43-
- postgres_data:/var/lib/postgresql/data
43+
- {{ project_slug }}_postgres_db:/var/lib/postgresql/data
4444
ports:
4545
- "5432:5432"
4646
healthcheck:
@@ -49,17 +49,17 @@ services:
4949
timeout: 5s
5050
retries: 5
5151
restart: unless-stopped
52-
{% elif database.value == "MySQL" %}
52+
{% elif database.value == "MySQL" %}
5353
mysql:
54-
image: mysql:8.0
55-
container_name: {{ project_slug }}_mysql
54+
image: mysql:8.4.8-oraclelinux9
55+
container_name: {{ project_slug }}_mysql_db
5656
environment:
5757
MYSQL_DATABASE: mydb
5858
MYSQL_USER: myuser
5959
MYSQL_PASSWORD: mypassword
6060
MYSQL_ROOT_PASSWORD: rootpassword
6161
volumes:
62-
- mysql_data:/var/lib/mysql
62+
- {{ project_slug }}_mysql_db:/var/lib/mysql
6363
ports:
6464
- "3306:3306"
6565
healthcheck:
@@ -68,12 +68,12 @@ services:
6868
timeout: 5s
6969
retries: 5
7070
restart: unless-stopped
71-
{% endif %}
71+
{% endif %}
7272

7373
{% if database.value == "PostgreSQL" %}
7474
volumes:
75-
postgres_data: {}
75+
{{ project_slug }}_postgres_db: {}
7676
{% elif database.value == "MySQL" %}
7777
volumes:
78-
mysql_data: {}
78+
{{ project_slug }}_mysql_db: {}
7979
{% endif %}

src/cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ def run_post_generation_setup(generator: ProjectGenerator, output_dir: Path) ->
204204
)
205205
console.print("[bold green]✓[/bold green] Docker infrastructure started")
206206

207+
# Create .dockerignore from .gitignore
208+
if config.docker:
209+
gitignore = output_dir / ".gitignore"
210+
dockerignore = output_dir / ".dockerignore"
211+
if gitignore.exists():
212+
shutil.copy(gitignore, dockerignore)
213+
207214
# Run plugin post-generation hooks
208215
generator.post_generate()
209216

@@ -212,7 +219,6 @@ def run_post_generation_setup(generator: ProjectGenerator, output_dir: Path) ->
212219
env_file = output_dir / ".env"
213220
if env_example.exists():
214221
shutil.copy(env_example, env_file)
215-
console.print("[bold green]✓[/bold green] Created .env from .env.example")
216222

217223
# Ask if user wants to start the application
218224
console.print()

0 commit comments

Comments
 (0)