Skip to content

Commit 971fb27

Browse files
committed
build: add Dockerfile
1 parent 9707493 commit 971fb27

File tree

4 files changed

+88
-5
lines changed

4 files changed

+88
-5
lines changed

.dockerignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
# Node
11+
node_modules
12+
dist
13+
dist-ssr
14+
*.local
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Cache files
27+
.eslintcache
28+
.stylelintcache
29+
30+
# Environment
31+
.env
32+
.env.*
33+
34+
# Markdown
35+
*.md
36+
LICENSE
37+
CODEOFCONDUCT
38+
CODEOWNERS
39+
40+
# Project files / dirs
41+
.gitlab
42+
.github
43+
.browserslistrc
44+
.editorconfig
45+
.eslintignore
46+
.eslintrc.js
47+
.gitignore
48+
.prettierignore
49+
.prettierrc
50+
.stylelintrc.json
51+
commitlint.config.js
52+
lerna.json
53+
nx.json

docker/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:16-bullseye-slim AS base
2+
WORKDIR /app
3+
ENV NODE_ENV=production
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends tini python3 make g++ \
6+
&& rm -rf /var/lib/apt/lists/* \
7+
&& chown -R node:node /app
8+
USER node
9+
COPY --chown=node:node package*.json yarn*.lock ./
10+
RUN yarn install --frozen-lockfile --prod && yarn cache clean --force
11+
EXPOSE 8080
12+
13+
14+
FROM base AS dev
15+
ENV NODE_ENV=development
16+
ENV CI=1
17+
ENV DOCKER=1
18+
#ENV PATH=/app/node_modules/.bin:$PATH
19+
RUN yarn install && yarn cache clean --force
20+
CMD ["yarn", "nodemon", "./packages/api/src/main.js"]
21+
22+
23+
FROM base AS builder
24+
COPY --chown=node:node . .
25+
RUN yarn build
26+
27+
28+
FROM base AS production
29+
ENTRYPOINT ["/usr/bin/tini", "--"]
30+
CMD ["node", "./packages/api/src/main.js"]

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"lint:style": "stylelint \"**/*.{css,scss,sass,vue}\" --ignore-path .gitignore",
1919
"dev": "yarn build && concurrently 'nx run-many --target=dev --all' 'sleep 1; open-cli http://127.0.0.1:8080'",
2020
"build": "nx run-many --target=build --all",
21-
"build:watch": "nx run-many --target=build --all",
22-
"prepare": "node ./.husky/prepare.js"
21+
"docker:up": "cd docker && docker compose -p soap up -d --build --force-recreate",
22+
"docker:down": "cd docker && docker compose -p soap down",
23+
"docker:build:app": "docker build --build-arg=\"APP_PATH=app\" --target app -t registry.gitlab.com/swarmlet/swarmlet/app:latest -f docker/Vue.Dockerfile .",
24+
"prepare": "test -n \"$DOCKER\" || node ./.husky/prepare.js"
2325
},
2426
"devDependencies": {
2527
"@babel/core": "^7.18.5",
@@ -40,6 +42,7 @@
4042
"husky": "^8.0.1",
4143
"lerna": "^5.1.4",
4244
"lint-staged": "^13.0.2",
45+
"nodemon": "^2.0.16",
4346
"nx": "^14.3.6",
4447
"open-cli": "^7.0.1",
4548
"postcss-html": "^1.4.1",

packages/api/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@
2020
"mongodb": "^4.7.0",
2121
"mongoose": "^6.4.0",
2222
"morgan": "^1.10.0"
23-
},
24-
"devDependencies": {
25-
"nodemon": "^2.0.16"
2623
}
2724
}

0 commit comments

Comments
 (0)