Skip to content

Commit f4acc16

Browse files
committed
fix: dockerfile for fly
1 parent 4999c5a commit f4acc16

File tree

5 files changed

+80
-8
lines changed

5 files changed

+80
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,5 @@ cython_debug/
163163
node_modules
164164
tsp-output/
165165
.aider*
166+
167+
demo_app/

agent/fullstack/README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ Generates full stack apps using trpc + shadcn components.
1414

1515
### Running generated code
1616

17-
Chande directory:
17+
Change directory:
1818

1919
`cd demo_app`
2020

2121
Configure postgres address:
2222

2323
`export DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres`
2424

25-
Apply migrations:
26-
27-
`bun run db:push`
28-
2925
Start the app:
3026

3127
`bun run dev:all`
@@ -36,4 +32,29 @@ Start the app:
3632

3733
### Running with docker - doesn't have hot reload
3834

35+
Change directory:
36+
37+
`cd demo_app`
38+
39+
Run through docker compose:
3940
`docker compose up --build`
41+
42+
This will apply DB migrations and start the server/client.
43+
44+
Just open the browser and go to `http://localhost:80`
45+
46+
### Deploying to fly
47+
48+
Change directory:
49+
50+
`cd demo_app`
51+
52+
Run the following command to deploy the app:
53+
54+
`fly deploy` - this will use the Dockerfile in the root to build the app.
55+
56+
If you don't have a fly.toml file, you can create one by running:
57+
58+
`fly launch`
59+
60+
This will create a new app and deploy it to fly.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Build stage for both client and server
2+
FROM oven/bun:1 as builder
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files
8+
COPY package.json bun.lockb ./
9+
COPY client/package.json ./client/
10+
COPY server/package.json ./server/
11+
12+
# Install dependencies
13+
RUN bun install --frozen-lockfile
14+
15+
# Copy source code
16+
COPY . .
17+
18+
# Build client and server
19+
RUN cd client && bun run build
20+
RUN cd server && bun run build
21+
22+
# Final stage - use oven/bun as base to avoid compatibility issues
23+
FROM oven/bun:1
24+
25+
# Install nginx directly
26+
RUN apt-get update && apt-get install -y nginx && apt-get clean
27+
28+
# Copy frontend files
29+
COPY --from=builder /app/client/dist /usr/share/nginx/html
30+
COPY ./client/nginx/nginx.conf /etc/nginx/conf.d/default.conf
31+
32+
# Modify nginx config - in fly it needs to be 8080
33+
RUN sed -i 's/listen 80;/listen 8080;/g' /etc/nginx/conf.d/default.conf
34+
RUN sed -i 's/app-backend/localhost/g' /etc/nginx/conf.d/default.conf
35+
36+
# Copy backend files
37+
COPY --from=builder /app/server /app/server
38+
COPY --from=builder /app/node_modules /app/node_modules
39+
40+
# Create a simple start script
41+
RUN echo '#!/bin/sh\nnginx &\ncd /app/server && bun run start:build' > /start.sh
42+
RUN chmod +x /start.sh
43+
44+
# Expose port
45+
EXPOSE 8080
46+
47+
# Use the script
48+
CMD ["/start.sh"]

agent/fullstack/prefabs/trpc_fullstack/server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"build": "tsc",
66
"dev": "bun --hot src/index.ts",
77
"db:push": "drizzle-kit push --force",
8-
"lint": "eslint --cache src/index.ts"
8+
"lint": "eslint --cache src/index.ts",
9+
"start:build": "drizzle-kit push --force && node dist/src/index.js"
910
},
1011
"dependencies": {
1112
"@trpc/server": "npm:@trpc/server@next",

agent/fullstack/prefabs/trpc_fullstack/server/server.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ RUN cd server && bun run build
2525
# Expose the server port
2626
EXPOSE 2022
2727

28-
# Run the server (adjust the path if needed)
29-
CMD ["node", "server/dist/src/index.js"]
28+
# Run the server
29+
CMD cd server && bun run start:build

0 commit comments

Comments
 (0)