Skip to content

Commit f93c663

Browse files
fix: web dockerfile + go versioning for air (#120)
1 parent 13658e7 commit f93c663

7 files changed

Lines changed: 72 additions & 33 deletions

File tree

apps/api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24-alpine AS builder
1+
FROM golang:1.25-alpine AS builder
22

33
RUN apk add --no-cache build-base ca-certificates
44

apps/api/cmd/email_worker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24-alpine AS base
1+
FROM golang:1.25-alpine AS base
22

33
WORKDIR /app
44

@@ -16,7 +16,7 @@ RUN go install github.com/air-verse/air@latest
1616
CMD ["air"]
1717

1818
# Production
19-
FROM base as prod
19+
FROM base AS prod
2020

2121
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o email_worker ./cmd/email_worker
2222

apps/web/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.vite
4+
.tanstack/tmp
5+
.env

apps/web/Caddyfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
app.swamphacks.com {
2+
reverse_proxy: web:5173
3+
4+
tls /etc/caddy/certs/prod_origin.crt /etc/caddy/certs/prod_origin.key
5+
encode gzip zstd
6+
7+
header {
8+
Strict-Transport-Security "max-age=31536000"
9+
X-Content-Type-Options "nosniff"
10+
X-Frame-Options "DENY"
11+
Referrer-Policy "strict-origin-when-cross-origin"
12+
}
13+
}
14+
15+
dev-app.swamphacks.com {
16+
reverse_proxy: dev-web:5173
17+
18+
tls /etc/caddy/certs/dev_origin.crt /etc/caddy/certs/dev_origin.key
19+
encode gzip zstd
20+
21+
header {
22+
Strict-Transport-Security "max-age=31536000"
23+
X-Content-Type-Options "nosniff"
24+
X-Frame-Options "DENY"
25+
Referrer-Policy "strict-origin-when-cross-origin"
26+
}
27+
}

apps/web/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ========== Base Stage ===========
2+
FROM node:22.16.0-slim AS base
3+
4+
WORKDIR /app
5+
6+
RUN npm install -g pnpm
7+
8+
COPY package.json pnpm-lock.yaml ./
9+
10+
RUN pnpm install --frozen-lockfile
11+
12+
COPY . .
13+
14+
# ========== Dev Stage ===========
15+
FROM base AS dev
16+
17+
EXPOSE 5173
18+
19+
CMD ["pnpm", "run", "dev", "--", "--host", "0.0.0.0"]
20+
21+
# ========== Build Stage ===========
22+
FROM base AS build
23+
RUN pnpm run build
24+
25+
# ========== Production Stage ===========
26+
FROM caddy:2-alpine AS prod
27+
28+
COPY --from=build /app/dist .
29+
30+
COPY Caddyfile /etc/caddy/Caddyfile
31+
32+
EXPOSE 80
33+
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

apps/web/Dockerfile.dev

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

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ services:
2727
web:
2828
build:
2929
context: ./apps/web
30-
dockerfile: Dockerfile.dev
30+
dockerfile: Dockerfile
31+
target: dev
3132
volumes:
32-
- ./apps/web:/app
33-
- web_node_modules:/app/node_modules
33+
- ./apps/web:/app:cached
34+
- /app/node_modules
3435
ports:
3536
- "5173:5173"
3637
environment:
@@ -71,6 +72,5 @@ services:
7172

7273
volumes:
7374
postgres_data:
74-
web_node_modules:
7575

7676

0 commit comments

Comments
 (0)