Prepare production version of backend

This commit is contained in:
arttu
2024-04-30 14:17:23 +03:00
parent e62cd48fa9
commit 294929ba19
6 changed files with 17 additions and 9 deletions
+2
View File
@@ -0,0 +1,2 @@
build
node_modules
+9 -4
View File
@@ -1,12 +1,15 @@
FROM node:20-alpine3.19 AS build
FROM node:20-alpine3.19 AS backend-build
ENV TZ="Europe/Helsinki"
WORKDIR /usr/src/app
COPY package*.json ./
COPY package.json ./
COPY package-lock.json ./
RUN npm install
ENV NODE_ENV=production
RUN npm ci
COPY . .
@@ -16,8 +19,10 @@ FROM node:20-alpine3.19 AS node-run
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build /usr/src/app
COPY --from=backend-build /usr/src/app/build /usr/src/app/build
COPY --from=backend-build /usr/src/app/node_modules /usr/src/app/node_modules
EXPOSE 4000
ENV NODE_ENV=production
CMD ["node", "build/index.js"]
+3 -1
View File
@@ -6,4 +6,6 @@ export const MARIADB_PASSWORD = process.env.MARIADB_PASSWORD as string
export const SECRET = process.env.SECRET as string
export const PORT = process.env.NOWDB_BACKEND_PORT as unknown as number
export const LOGIN_VALID_MS = parseInt(process.env.LOGIN_VALID_MINUTES as string) * 60 * 1000
export const MARIADB_PORT = parseInt(process.env.MARIADB_PORT as string)
export const MARIADB_PORT = parseInt(process.env.MARIADB_PORT as string)
export const USER_CREATION_SECRET = process.env.USER_CREATION_SECRET as string
export const BACKEND_MODE = (process.env.BACKEND_MODE as 'dev' | 'prod' | 'test')
+1 -3
View File
@@ -14,9 +14,7 @@ services:
container_name: nowdb-backend
build:
context: backend/
env_file: .db.dev.env
volumes:
- ./backend/:/usr/src/app
env_file: .db.env
ports:
- 4000:4000
db:
+1
View File
@@ -0,0 +1 @@
dist
+1 -1
View File
@@ -7,7 +7,7 @@ WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm install
RUN npm ci
COPY . .