Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
reduce the size of docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Mar 8, 2022
1 parent 161abbe commit 4fe3a4e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Deps
FROM node:16-buster as base
FROM node:16-alpine as base
WORKDIR /app
# RUN apt-get update && \
# apt-get upgrade -y --no-install-recommends && \
# apt-get install -y --no-install-recommends openssl && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*
RUN apk update
RUN apk add python3 make gcc g++
COPY package.json .
COPY prisma prisma
COPY yarn.lock .
Expand All @@ -15,10 +12,9 @@ COPY tsconfig.json .
# Build
FROM base as build
WORKDIR /app


COPY src ./src
RUN yarn install --frozen-lockfile
RUN yarn install
RUN yarn cache clean
RUN yarn build:tsup

# Runner
Expand All @@ -30,7 +26,8 @@ ENV DATABASE_URL "file:/app/config/db.sqlite"
ARG DRONE_TAG
ENV VERSION=$DRONE_TAG
COPY --from=build /app/dist dist
RUN yarn install --frozen-lockfile --production
RUN yarn install --production
RUN yarn cache clean
# CMD yarn deploy && echo "Test" && yarn start
CMD ls dist && yarn deploy && npx prisma migrate deploy && yarn start

Expand All @@ -44,8 +41,9 @@ ARG DRONE_TAG
ENV VERSION=$DRONE_TAG
WORKDIR /app
COPY --from=build /app/dist dist
RUN yarn install --frozen-lockfile --production
RUN useradd container -m -s /bin/bash
RUN yarn install --production
RUN yarn cache clean
RUN adduser -H -D container
USER container

COPY entrypoint.sh /entrypoint.sh
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@discordjs/builders": "^0.12.0",
"@discordjs/rest": "^0.3.0",
"@prisma/client": "^3.10.0",
"@swc/core": "^1.2.151",
"apollo-server-core": "^3.6.3",
"apollo-server-express": "^3.6.3",
"bufferutil": "^4.0.6",
Expand Down Expand Up @@ -57,6 +56,8 @@
"@types/node": "^17.0.5",
"@types/romans": "^2.0.0",
"@types/signale": "^1.4.2",
"@swc/core": "^1.2.151",
"node-prune": "^1.0.2",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"prettier-plugin-organize-imports": "^2.3.4",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"resolveJsonModule": true,

// Language and Environment
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
// "emitDecoratorMetadata": true,
// "experimentalDecorators": true,
"lib": ["esnext", "DOM"],
"target": "esnext",
"useDefineForClassFields": true,
Expand Down
2 changes: 2 additions & 0 deletions tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default defineConfig((options) => ({
platform: "node",
minify: !options.watch,
tsconfig: "tsconfig.json",
bundle: true,
dts: true,
}));
17 changes: 11 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=

"@sapphire/async-queue@^1.1.9":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@sapphire/async-queue/-/async-queue-1.2.0.tgz#7a56afd318101d338433d7180ebd6af349243268"
integrity sha512-O5ND5Ljpef86X5oy8zXorQ754TMjWALcPSAgPBu4+76HLtDTrNoDyzU2uGE2G4A8Wv51u0MXHzGQ0WZ4GMtpIw==
version "1.3.0"
resolved "https://registry.yarnpkg.com/@sapphire/async-queue/-/async-queue-1.3.0.tgz#98b1b364a5fe820366a786827f2e987590de5964"
integrity sha512-z+CDw5X4UgIEpZL8KM+ThVx1i8V60HBg0l/oFewTNbQQeRDJHdVxHyJykv+SF1H+Rc8EkMS81VTWo95jVYgO/g==

"@sapphire/snowflake@^3.0.1":
version "3.2.0"
Expand Down Expand Up @@ -1789,6 +1789,11 @@ node-gyp-build@^4.3.0:
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3"
integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==

node-prune@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/node-prune/-/node-prune-1.0.2.tgz#003b3edf886ab1f67e3915102d6c4835f3087181"
integrity sha512-WSDCF2F/ad+IZp7Gx9b5l8TT3ezP56pn0pCSm4nnkUT00rP1yuOHCapv+jKy/Q87ZqYcPtV4Z+2IifozGDpR0Q==

nodemon@^2.0.15:
version "2.0.15"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.15.tgz#504516ce3b43d9dc9a955ccd9ec57550a31a8d4e"
Expand Down Expand Up @@ -2525,9 +2530,9 @@ xdg-basedir@^4.0.0:
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==

xss@^1.0.8:
version "1.0.10"
resolved "https://registry.yarnpkg.com/xss/-/xss-1.0.10.tgz#5cd63a9b147a755a14cb0455c7db8866120eb4d2"
integrity sha512-qmoqrRksmzqSKvgqzN0055UFWY7OKx1/9JWeRswwEVX9fCG5jcYRxa/A2DHcmZX6VJvjzHRQ2STeeVcQkrmLSw==
version "1.0.11"
resolved "https://registry.yarnpkg.com/xss/-/xss-1.0.11.tgz#211cb82e95b5071d4c75d597283c021157ebe46a"
integrity sha512-EimjrjThZeK2MO7WKR9mN5ZC1CSqivSl55wvUK5EtU6acf0rzEE1pN+9ZDrFXJ82BRp3JL38pPE6S4o/rpp1zQ==
dependencies:
commander "^2.20.3"
cssfilter "0.0.10"
Expand Down

0 comments on commit 4fe3a4e

Please sign in to comment.