Skip to content

Commit a8f4301

Browse files
authored
Prod build (#10)
* add production build dockerfile * bump version to 0.4.2; fix nginx port
1 parent 856d7d7 commit a8f4301

File tree

6 files changed

+33
-20
lines changed

6 files changed

+33
-20
lines changed

api/Dockerfile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
FROM node:18
2-
1+
FROM node:18 AS builder
32
WORKDIR /app
43
COPY package.json .
5-
RUN yarn
6-
4+
COPY yarn.lock .
5+
RUN yarn install --frozen-lockfile
76
COPY . .
8-
# this will modify node_modules/@prisma/client
9-
RUN yarn run prisma generate
7+
RUN yarn build
108

11-
CMD ["yarn", "dev"]
9+
FROM node:18 AS server
10+
WORKDIR /app
11+
COPY package.json .
12+
COPY yarn.lock .
13+
RUN yarn install --production
14+
COPY prisma .
15+
RUN yarn run prisma generate
16+
COPY --from=builder ./app/build ./build
17+
EXPOSE 4000
18+
CMD ["yarn", "start"]

api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "MIT",
66
"scripts": {
77
"build": "tsc",
8+
"start": "node build/start-server.js",
89
"dev": "ts-node-dev src/start-server.ts",
910
"test": "jest --config jest.config.js"
1011
},

api/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "esnext",
3+
"module": "commonjs",
44
"outDir": "./build",
55
"target": "esnext",
66
"allowJs": true,

deploy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
Build the docker images:
44

55
```
6-
docker build -t lihebi/codepod-ui:v0.1.0 ./ui
7-
docker build -t lihebi/codepod-api:v0.1.0 ./api
6+
docker build -t lihebi/codepod-ui:v0.4.2 ./ui
7+
docker build -t lihebi/codepod-api:v0.4.2 ./api
88
docker build -t lihebi/codepod_kernel_python:v0.1.0 ./api/kernels/python
99
```
1010

1111
Push to registry:
1212

1313
```
14-
docker push lihebi/codepod-ui:v0.1.0
15-
docker push lihebi/codepod-api:v0.1.0
14+
docker push lihebi/codepod-ui:v0.4.2
15+
docker push lihebi/codepod-api:v0.4.2
1616
docker push lihebi/codepod_kernel_python:v0.1.0
1717
```
1818

k8s/deployments/codepod-05-app.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ spec:
1818
spec:
1919
containers:
2020
- name: codepod-ui
21-
image: lihebi/codepod-ui:v0.2.0
21+
image: lihebi/codepod-ui:v0.4.2
2222
ports:
23-
- containerPort: 3000
23+
- containerPort: 80
2424

2525
---
2626
apiVersion: v1
@@ -33,7 +33,7 @@ spec:
3333
ports:
3434
- protocol: TCP
3535
port: 80
36-
targetPort: 3000
36+
targetPort: 80
3737

3838
# API
3939
---
@@ -55,7 +55,7 @@ spec:
5555
spec:
5656
containers:
5757
- name: codepod-api
58-
image: lihebi/codepod-api:v0.2.0
58+
image: lihebi/codepod-api:v0.4.2
5959
ports:
6060
- containerPort: 4000
6161
env:

ui/Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
FROM node:18
1+
FROM node:18 AS builder
22

33
WORKDIR /app
4-
COPY ./package.json package.json
5-
RUN yarn
4+
COPY package.json .
5+
COPY yarn.lock .
6+
RUN yarn install --frozen-lockfile
67

8+
# FIXME would this copy node_modules?
79
COPY . .
810

9-
CMD ["yarn", "start"]
11+
RUN yarn build
12+
13+
FROM nginx:1.19-alpine AS server
14+
COPY --from=builder ./app/build /usr/share/nginx/html

0 commit comments

Comments
 (0)