Skip to content

Commit b4384ac

Browse files
committed
ci: set prod env for frontend and fix docker deployment for backend
1 parent 68c4813 commit b4384ac

9 files changed

Lines changed: 55 additions & 53 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ lerna-debug.log*
2929

3030

3131
dist
32+
33+
apps/frontend
34+
.github

.github/workflows/deploy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
uses: superfly/flyctl-actions/setup-flyctl@master
5151

5252
- name: Deploy to Fly.io
53-
working-directory: ./apps/backend
5453
run: flyctl deploy --remote-only
5554
env:
5655
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ node_modules/
1414

1515
# env
1616
.env
17-
.env.production
1817

1918
# logs
2019
logs/

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Adjust NODE_VERSION as desired
4+
ARG NODE_VERSION=22.9.0
5+
# Adjust NODE_VERSION as desired
6+
ARG DISTROLESS_NODE_VERSION=22
7+
8+
FROM node:${NODE_VERSION}-slim AS build
9+
10+
LABEL fly_launch_runtime="Node.js"
11+
# Install pnpm
12+
ENV PNPM_HOME="/pnpm"
13+
ENV PATH="$PNPM_HOME:$PATH"
14+
RUN npm install -g corepack@latest
15+
RUN corepack enable
16+
17+
# Node.js app lives here
18+
WORKDIR /app
19+
COPY . .
20+
21+
# Install node modules
22+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
23+
pnpm install --frozen-lockfile
24+
25+
# Build application
26+
RUN pnpm --filter @periodos/backend build
27+
28+
# prune deps
29+
RUN pnpm --filter @periodos/backend --prod deploy --legacy output
30+
31+
# use node slim for debugging capabilities
32+
# FROM node:${NODE_VERSION}-slim
33+
34+
# use distroless for smaller image if needed
35+
FROM gcr.io/distroless/nodejs${DISTROLESS_NODE_VERSION}-debian12
36+
37+
WORKDIR /app
38+
39+
# Set production environment
40+
ENV NODE_ENV="production"
41+
42+
# Copy built application
43+
COPY --from=build /app/output /app
44+
# Start the server by default, this can be overwritten at runtime
45+
EXPOSE 3000
46+
CMD [ "dist/index.js" ]

apps/backend/Dockerfile

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

apps/backend/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
},
2222
"exports": {
2323
"./routes": "./src/routes/index.ts"
24-
}
24+
},
25+
"files": [
26+
"dist"
27+
]
2528
}

apps/frontend/.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE='https://periodos.fly.dev'
File renamed without changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6-
"packageManager": "pnpm@10.0.0",
6+
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"dev": "pnpm --parallel --filter '@periodos/*' dev"

0 commit comments

Comments
 (0)