Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit cb8b0ed

Browse files
authored
Merge pull request #32 from bytes-zone/build-in-docker
build in docker
2 parents b9acdf5 + 7e8bf51 commit cb8b0ed

File tree

7 files changed

+228
-9
lines changed

7 files changed

+228
-9
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
Dockerfile

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,42 @@ jobs:
4040
name: playwright-report
4141
path: playwright-report/
4242
retention-days: 30
43+
44+
container:
45+
name: Container
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v5
49+
- run: docker build -t blocks:test .
50+
51+
- name: run and check
52+
run: |
53+
docker run -d --name blocks -p 3000:3000 blocks:test
54+
55+
# Wait for container to be ready (up to 30 seconds)
56+
echo "Waiting for container to start..."
57+
for i in {1..30}; do
58+
if curl -f -s http://localhost:3000 > /dev/null 2>&1; then
59+
echo "Container is ready!"
60+
break
61+
fi
62+
echo "Attempt $i/30: Container not ready yet, waiting..."
63+
sleep 1
64+
done
65+
66+
- name: health check
67+
run: |
68+
echo "Checking health..."
69+
RESP="$(curl -Ss http://localhost:3000/health)"
70+
if test "$RESP" != "OK"; then
71+
printf "Health check failed! Here's what we got:\n\n%s\n\n" "$RESP"
72+
exit 1
73+
fi
74+
echo "Health check passed!"
75+
76+
- name: stop container
77+
if: always()
78+
run: |
79+
echo "Stopping Docker container..."
80+
docker stop blocks || true
81+
docker rm blocks || true

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:24 AS build
2+
3+
RUN npm install -g pnpm
4+
5+
ENV NODE_ENV=production
6+
7+
# Install deps
8+
COPY package.json pnpm-lock.yaml /app/
9+
WORKDIR /app
10+
RUN pnpm install
11+
12+
# Build the app
13+
COPY . /app
14+
RUN pnpm run build
15+
16+
# Prepare production image
17+
FROM node:24 AS run
18+
19+
ENV NODE_ENV=production
20+
21+
RUN npm install -g pnpm
22+
23+
COPY package.json pnpm-lock.yaml /app/
24+
WORKDIR /app
25+
RUN pnpm install --production
26+
27+
COPY --from=build /app/build /app
28+
WORKDIR /app
29+
CMD ["node", "index.js"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@lucide/svelte": "0.542.0",
2727
"@oddbird/css-anchor-positioning": "0.6.1",
2828
"@playwright/test": "1.55.0",
29-
"@sveltejs/adapter-auto": "6.1.0",
29+
"@sveltejs/adapter-node": "5.3.1",
3030
"@sveltejs/kit": "2.37.0",
3131
"@sveltejs/vite-plugin-svelte": "6.1.4",
3232
"@testing-library/svelte": "5.2.8",

0 commit comments

Comments
 (0)