-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
57 lines (45 loc) · 1.68 KB
/
Dockerfile.prod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.2 AS base
RUN mkdir -p /app
WORKDIR /app
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
COPY patches/ /temp/dev/patches/
RUN
RUN ls /temp/dev && cd /temp/dev && bun install --frozen-lockfile
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
COPY patches/ /temp/prod/patches/
RUN cd /temp/prod && bun install --frozen-lockfile --production
# Install Restate CLI globally
RUN apt-get -y update; apt-get -y install curl
RUN BIN=/usr/local/bin && RESTATE_PLATFORM=aarch64-unknown-linux-musl && \
curl -LO https://github.com/restatedev/restate/releases/latest/download/restate.$RESTATE_PLATFORM.tar.gz && \
tar -xvf restate.$RESTATE_PLATFORM.tar.gz && \
chmod +x restate && \
mv restate $BIN
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
# tests & build
ENV NODE_ENV=production
COPY .env.prod .env
RUN bun run check && bun run bundle
# copy production dependencies and source code into final image
FROM node:slim AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=install /usr/local/bin/restate /usr/local/bin/restate
COPY --from=prerelease /app/dist/* ./dist/
COPY --from=prerelease /app/package.json .
COPY .env.prod .env
# run the app
EXPOSE 9080/tcp
ENV NODE_ENV=production
ENTRYPOINT ["node","--enable-source-maps","./dist/app.js"]