|
| 1 | +# docker build -t sqlitcloud-gateway . |
| 2 | +# docker run -p 8090:8090 -p 4000:4000 --name sqlitecloud-gateway sqlitecloud-gateway |
| 3 | + |
| 4 | +# use the official Bun image |
| 5 | +# see all versions at https://hub.docker.com/r/oven/bun/tags |
| 6 | +FROM oven/bun:1 as base |
| 7 | +WORKDIR /usr/src/app |
| 8 | + |
| 9 | +# install dependencies into temp directory |
| 10 | +# this will cache them and speed up future builds |
| 11 | +FROM base AS install |
| 12 | +RUN mkdir -p /temp/dev |
| 13 | +COPY package.json bun.lockb /temp/dev/ |
| 14 | +RUN cd /temp/dev && bun install --frozen-lockfile |
| 15 | + |
| 16 | +# install with --production (exclude devDependencies) |
| 17 | +RUN mkdir -p /temp/prod |
| 18 | +COPY package.json bun.lockb /temp/prod/ |
| 19 | +RUN cd /temp/prod && bun install --frozen-lockfile --production |
| 20 | + |
| 21 | +# copy node_modules from temp directory |
| 22 | +# then copy all (non-ignored) project files into the image |
| 23 | +FROM base AS prerelease |
| 24 | +COPY --from=install /temp/dev/node_modules node_modules |
| 25 | +COPY . . |
| 26 | + |
| 27 | +# [optional] tests & build |
| 28 | +ENV NODE_ENV=production |
| 29 | +#RUN bun test |
| 30 | +#RUN bun run build |
| 31 | +RUN bun build ./src/gateway/gateway.ts --compile --outfile ./sqlitecloud-gateway.out |
| 32 | + |
| 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/src ./src |
| 37 | +COPY --from=prerelease /usr/src/app/public ./public |
| 38 | +COPY --from=prerelease /usr/src/app/package.json . |
| 39 | +COPY --from=prerelease /usr/src/app/sqlitecloud-gateway.out . |
| 40 | + |
| 41 | +# run the app |
| 42 | +USER bun |
| 43 | + |
| 44 | +EXPOSE 4000/tcp |
| 45 | +EXPOSE 8090/tcp |
| 46 | + |
| 47 | +#ENTRYPOINT [ "bun", "run", "./src/gateway/gateway.ts" ] |
| 48 | +ENTRYPOINT [ "./sqlitecloud-gateway.out" ] |
0 commit comments