docker: update dockerfile to use rollup

This commit is contained in:
liushuyu 2022-09-14 03:04:27 -06:00
parent 749bbdeb9d
commit 0e5f158f11
No known key found for this signature in database
GPG Key ID: 23D1CE4534419437
3 changed files with 17 additions and 6 deletions

View File

@ -4,9 +4,9 @@ FROM node:16-alpine AS build
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Install app dependencies and add source files # Install app dependencies and add source files
COPY package.json yarn.lock tsconfig.json ./ COPY package.json env.json yarn.lock tsconfig.json bundle.sh *.js ./
COPY src/ ./src COPY ./src ./src
RUN yarn install --frozen-lockfile && yarn build && rm -f dist/*.map RUN yarn install --frozen-lockfile && sh -e ./bundle.sh
# Second stage # Second stage
FROM node:16-alpine FROM node:16-alpine
@ -15,9 +15,6 @@ WORKDIR /usr/src/app
# Copy artifacts # Copy artifacts
COPY --from=build /usr/src/app/dist/ ./ COPY --from=build /usr/src/app/dist/ ./
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY env.json src/responses.json ./
COPY src/responses ./responses/
RUN addgroup -S app -g 50000 && \ RUN addgroup -S app -g 50000 && \
adduser -S -g app -u 50000 app && \ adduser -S -g app -u 50000 app && \

13
bundle.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash -e
yarn
[ -d "dist" ] && rm -rf dist
yarn run build
echo "[+] Installing non-bundle-able packages ..."
DISCORD_JS="$(grep discord.js package.json | sed 's|,||')"
cd "dist"
echo "{\"name\": \"citra-discord-bot\",\"license\": \"GPL-2.0+\",\"dependencies\": {${DISCORD_JS}}}" > package.json
yarn install

View File

@ -46,6 +46,7 @@
"postinstall": "node generateExports.js", "postinstall": "node generateExports.js",
"build": "yarn run rollup -c", "build": "yarn run rollup -c",
"check": "yarn run tsc --noEmit", "check": "yarn run tsc --noEmit",
"bundle": "./bundle.sh",
"serve": "yarn run ts-node ./src/server.ts" "serve": "yarn run ts-node ./src/server.ts"
} }
} }