1
- # use the official Bun image
2
- # see all versions at https://hub.docker.com/r/oven/bun/tags
1
+ # use the official bun image
3
2
FROM oven/bun:latest as base
4
3
WORKDIR /usr/src/app
5
4
6
- # Set environment variables
5
+ # set environment variables
7
6
ENV RATE_LIMIT="200"
8
7
ENV DATABASE_URL="file:./database/data.db"
9
8
ENV HISTORY_API_URL="https://helldivers-b.omnedia.com/api"
@@ -20,8 +19,6 @@ RUN cd /temp/dev && bun install --frozen-lockfile
20
19
# install with --production (exclude devDependencies)
21
20
RUN mkdir -p /temp/prod
22
21
COPY package.json bun.lockb /temp/prod/
23
-
24
- # install production dependencies
25
22
RUN cd /temp/prod && bun install --frozen-lockfile --production
26
23
27
24
# copy node_modules from temp directory
@@ -30,36 +27,31 @@ FROM base AS prerelease
30
27
COPY --from=install /temp/dev/node_modules node_modules
31
28
COPY . .
32
29
33
- # copy production dependencies and source code into final image
34
- FROM base AS release
35
- COPY --from=install /temp/prod/node_modules node_modules
36
- COPY --from=prerelease /usr/src/app/package.json .
37
- COPY --from=prerelease /usr/src/app .
38
-
39
- # set the environment to production
40
- ENV NODE_ENV=production
41
-
42
- # create the database
30
+ # synchronize the database schema & generate client
43
31
RUN bunx prisma migrate deploy
44
- RUN bunx prisma db push --skip-generate
32
+ RUN bunx prisma db push
45
33
46
- # create primsa client
47
- RUN bunx prisma generate
34
+ # generate source data for the api
35
+ RUN bun run generate
48
36
49
- # build the app
50
- RUN bun run output
37
+ # test generated source data
38
+ RUN bun test
51
39
52
- # upload source maps to sentry
53
- ARG SOURCE_MAP_TOKEN
54
- ENV SENTRY_AUTH_TOKEN=${SOURCE_MAP_TOKEN}
55
- # install ca-certificates if not running in GitHub action runner
56
- RUN if [ -z "${SOURCE_MAP_TOKEN}" ]; then echo "CA certificate install not required" ; else apt-get -y update && apt-get -y install ca-certificates; fi
57
- RUN if [ -z "${SOURCE_MAP_TOKEN}" ]; then echo "Sourcemap upload not executed. GitHub action runner detected." ; else bun run sentry:sourcemaps; fi
40
+ # copy production dependencies and source code into final image
41
+ FROM base AS release
42
+ COPY --from=prerelease /usr/src/app/src src
43
+ COPY --from=prerelease /usr/src/app/prisma prisma
44
+ COPY --from=prerelease /usr/src/app/node_modules node_modules
45
+ COPY --from=prerelease /usr/src/app/package.json package.json
46
+ COPY --from=prerelease /usr/src/app/tsconfig.json tsconfig.json
58
47
59
- # create a non-root use
60
- RUN chmod a+rw prisma/database prisma/database/*
48
+ # src directory permissions
49
+ RUN chown -R bun:bun /usr/src/app
50
+
51
+ # set production environment
52
+ ENV NODE_ENV=production
61
53
62
54
# run the app
63
55
USER bun
64
56
EXPOSE 3000/tcp
65
- ENTRYPOINT ["bun" , "--smol " , "run " , "build /index.js " ]
57
+ ENTRYPOINT ["bun" , "run " , "--smol " , "src /index.ts " ]
0 commit comments