Skip to content

Commit 5ed7bc1

Browse files
committed
fix: ensure frontend is built before Docker build for go:embed
- Add frontend build step to Docker CI job before Docker build - Update .dockerignore to explicitly include web/dist/ and web/embed.go - Add verification step in Dockerfile to ensure web/dist exists - Frontend must be built in CI before Docker build due to go:embed directive This fixes the go:embed build failure while maintaining optimized build times. The frontend is built once in CI, then the pre-built assets are embedded.
1 parent 676b343 commit 5ed7bc1

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ web/tailwind.config.js
3737
web/postcss.config.js
3838
web/tsconfig.json
3939
web/tsconfig.node.json
40+
# Keep web/dist/ and web/embed.go - needed for go:embed
41+
!web/dist/
42+
!web/embed.go
4043

4144
# Logs
4245
*.log

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ jobs:
124124
- name: Checkout code
125125
uses: actions/checkout@v4
126126

127+
- name: Set up Node.js
128+
uses: actions/setup-node@v4
129+
with:
130+
node-version: "18"
131+
cache: "npm"
132+
cache-dependency-path: web/package-lock.json
133+
134+
- name: Build frontend
135+
run: |
136+
cd web
137+
npm ci
138+
npm run build
139+
127140
- name: Set up Docker Buildx
128141
uses: docker/setup-buildx-action@v3
129142

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ WORKDIR /app
1414
COPY go.mod go.sum ./
1515
RUN go mod download
1616

17-
# Copy source code and pre-built frontend
17+
# Copy source code (frontend should be pre-built by CI)
1818
COPY . .
1919

20+
# Verify frontend dist exists (required for go:embed)
21+
RUN ls -la web/dist/ || (echo "ERROR: web/dist directory missing! Frontend must be built before Docker build." && exit 1)
22+
2023
# Build the binary with optimizations
2124
RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o vertex
2225

0 commit comments

Comments
 (0)