Skip to content

Commit

Permalink
chore: Do best practices and Bump dependencies (#47)
Browse files Browse the repository at this point in the history
* chore: Do best practices

* chore: Remove chown

* chore: Make web multi-stage

* chore: Specify USER and tidy up

* refactor: Fix lint error

* chore: Bump dependencies

* chore: Fix COPY path
  • Loading branch information
MikuroXina committed May 30, 2022
1 parent 260ad14 commit 1994b92
Show file tree
Hide file tree
Showing 7 changed files with 1,225 additions and 1,072 deletions.
21 changes: 14 additions & 7 deletions docker/bot.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM node:16-alpine as BUILD

COPY . .
WORKDIR /work

RUN npm install --no-save && npm run build:bot
COPY package.json .
RUN npm install --no-save

COPY tsconfig.json .
COPY src/ ./src
RUN npm run build:bot

# ---

Expand All @@ -11,13 +16,15 @@ FROM node:16-alpine
RUN addgroup -g 1993 -S bot \
&& adduser -u 1993 -S bot -G bot

COPY package.json /app/
COPY --from=BUILD node_modules/ /app/node_modules/
COPY --from=BUILD dist/bundle.js /app/dist/bundle.js
COPY analecta/ /app/analecta/
WORKDIR /app

RUN chown bot:bot /app
COPY package.json .
COPY --from=BUILD work/node_modules/ ./node_modules/
COPY --from=BUILD work/dist/bundle.js ./dist/bundle.js
COPY analecta/ ./analecta/

VOLUME [ "/app/.cache" ]

USER bot

ENTRYPOINT [ "npm", "run", "start:bot" ]
20 changes: 15 additions & 5 deletions docker/web.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM node:16-alpine

EXPOSE 3000
FROM node:16-alpine as BUILD

RUN addgroup -g 1994 -S web \
&& adduser -u 1994 -S web -G web
Expand All @@ -12,9 +10,21 @@ RUN npm install --no-save

COPY tsconfig.json /app/
COPY src/web/ /app/
RUN npx next build \
&& chown web:web /app
RUN npx next build

FROM node:16-alpine

EXPOSE 3000

WORKDIR /app

COPY --from=BUILD /app/node_modules/ .
COPY package.json .
COPY --from=BUILD /app/.next/ .

USER web

HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost:3000/ || exit 1

ENTRYPOINT [ "npx", "next", "start" ]
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"@babel/core": "^7.16.12",
"discord.js": "^13.6.0",
"@babel/core": "^7.18.2",
"discord.js": "^13.7.0",
"dotenv": "^10.0.0",
"faunadb": "^4.4.1",
"faunadb": "^4.5.4",
"mutex-promise": "^0.1.0",
"next": "^11.1.4",
"node-fetch": "^2.6.7",
Expand All @@ -30,22 +30,23 @@
"toml": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^27.4.0",
"@types/node": "^16.11.21",
"@types/node-fetch": "^2.5.12",
"@types/react": "^17.0.38",
"@next/eslint-plugin-next": "^12.1.6",
"@types/jest": "^27.5.1",
"@types/node": "^16.11.36",
"@types/node-fetch": "^2.6.1",
"@types/react": "^17.0.45",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"esbuild": "~0.14.14",
"esbuild": "~0.14.42",
"eslint": "^7.32.0",
"eslint-config-next": "^11.1.4",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-react": "^7.28.0",
"jest": "^27.4.7",
"prettier": "^2.5.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
"eslint-plugin-react": "^7.30.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.5",
"ts-node": "^10.8.0",
"typescript": "<4.5.0"
}
}
Loading

0 comments on commit 1994b92

Please sign in to comment.