Spaces:
Sleeping
Sleeping
Commit
·
dbf2e7d
1
Parent(s):
fa01d80
dockerize
Browse files- .dockerignore +7 -0
- Dockerfile +38 -0
.dockerignore
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
npm-debug.log
|
| 3 |
+
.env
|
| 4 |
+
.git
|
| 5 |
+
.gitignore
|
| 6 |
+
logs/*
|
| 7 |
+
dist
|
Dockerfile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# use the official Bun image
|
| 2 |
+
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
| 3 |
+
FROM oven/bun:1 AS base
|
| 4 |
+
WORKDIR /usr/src/app
|
| 5 |
+
|
| 6 |
+
# install dependencies into temp directory
|
| 7 |
+
# this will cache them and speed up future builds
|
| 8 |
+
FROM base AS install
|
| 9 |
+
RUN mkdir -p /temp/dev
|
| 10 |
+
COPY package.json bun.lock* /temp/dev/
|
| 11 |
+
RUN cd /temp/dev && bun install --frozen-lockfile
|
| 12 |
+
|
| 13 |
+
# install with --production (exclude devDependencies)
|
| 14 |
+
RUN mkdir -p /temp/prod
|
| 15 |
+
COPY package.json bun.lock* /temp/prod/
|
| 16 |
+
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
| 17 |
+
|
| 18 |
+
# copy node_modules from temp directory
|
| 19 |
+
# then copy all (non-ignored) project files into the image
|
| 20 |
+
FROM base AS prerelease
|
| 21 |
+
COPY --from=install /temp/dev/node_modules node_modules
|
| 22 |
+
COPY . .
|
| 23 |
+
|
| 24 |
+
# [optional] tests & build
|
| 25 |
+
ENV NODE_ENV=production
|
| 26 |
+
RUN mkdir -p logs
|
| 27 |
+
|
| 28 |
+
# copy production dependencies and source code into final image
|
| 29 |
+
FROM base AS release
|
| 30 |
+
COPY --from=install /temp/prod/node_modules node_modules
|
| 31 |
+
COPY --from=prerelease /usr/src/app/index.ts .
|
| 32 |
+
COPY --from=prerelease /usr/src/app/package.json .
|
| 33 |
+
RUN mkdir -p logs
|
| 34 |
+
|
| 35 |
+
# run the app
|
| 36 |
+
USER bun
|
| 37 |
+
EXPOSE 4040/tcp
|
| 38 |
+
ENTRYPOINT [ "bun", "run", "index.ts" ]
|