Skip to content

Commit b95d716

Browse files
committed
complete docker build
1 parent 82473bd commit b95d716

File tree

5 files changed

+101
-14
lines changed

5 files changed

+101
-14
lines changed

backend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/node_modules
2+
**/dist
3+
**/coverage
4+
**/build
5+
**/logs
6+
**/tmp

backend/Dockerfile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
# Use an nginx image to serve the built application
2-
FROM node:22
1+
# Build stage
2+
FROM node:22 AS base
33

4-
WORKDIR /app
5-
COPY package*.json ./
6-
RUN npm install . --force
4+
WORKDIR /app
5+
COPY backend/package*.json /app
6+
RUN npm install --force
77

8-
COPY . /app/
9-
RUN npm run build
10-
11-
WORKDIR /app/dist
8+
COPY backend/ /app
129

1310
EXPOSE 5000
1411

15-
CMD ["node", "server.js"]
12+
# Development image
13+
FROM base AS dev
14+
CMD ["npm", "run", "dev"]
15+
16+
# Production image
17+
FROM base AS build
18+
RUN npm run build
19+
CMD ["node", "dist/index.js"]
20+
21+
# Ideally we want to use nginx
22+
# FROM nginx:alpine AS prod
23+
# COPY --from=build /app/dist/ /usr/share/nginx/html/
24+
# EXPOSE 80
25+
# CMD ["nginx", "-g", "daemon off;"]

backend/package-lock.json

Lines changed: 62 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
"main": "./lib/index.js",
66
"scripts": {
77
"test": "test",
8-
"build": "tsc",
8+
"build": "tsc && npm run copy-non-ts-files",
99
"lint": "tslint -c tslint.json src/**/*.ts",
1010
"dev": "ts-node-dev --respawn --transpile-only --ignore-watch node_modules --watch src src/index.tsx",
11-
"start:hot": "ts-node-dev --respawn --transpile-only --ignore-watch node_modules --watch src src/index.tsx"
11+
"start:hot": "ts-node-dev --respawn --transpile-only --ignore-watch node_modules --watch src src/index.tsx",
12+
"start": "node dist/index.js",
13+
"copy-non-ts-files": "cp -r src/docs dist/docs",
14+
"copy-non-ts-files-win": "xcopy /E /I /Y src\\docs dist\\docs"
1215
},
1316
"repository": {
1417
"type": "git",
@@ -30,6 +33,8 @@
3033
"express": "^5.1.0",
3134
"pg": "^8.16.0",
3235
"sequelize": "^6.37.7",
36+
"swagger-ui-express": "^5.0.1",
37+
"yamljs": "^0.3.0",
3338
"tslint": "^6.1.3"
3439
},
3540
"files": [
@@ -44,6 +49,8 @@
4449
"@types/node": "^24.0.1",
4550
"@types/pg": "^8.15.4",
4651
"@types/sequelize": "^4.28.20",
52+
"@types/swagger-ui-express": "^4.1.8",
53+
"@types/yamljs": "^0.2.34",
4754
"ts-node": "^10.9.2",
4855
"ts-node-dev": "^2.0.0",
4956
"typescript": "^5.8.3"

backend/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
},
3535
"include": [
3636
"typings/**/*",
37-
"src/**/*"
37+
"src/**/*",
38+
],
39+
"exclude": [
40+
"src/docs/**/*"
3841
]
3942
}

0 commit comments

Comments
 (0)