Repository navigation
Expand file tree
/
Copy pathDockerfile.server
More file actions
67 lines (55 loc) · 2.72 KB
/
Copy pathDockerfile.server
File metadata and controls
67 lines (55 loc) · 2.72 KB
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
58
59
60
61
62
63
64
65
66
67
# syntax=docker/dockerfile:1
FROM node:26.13.0-trixie-slim@sha256:5adad64f9a1fca2d51972caa65983634c8a774eb300d72b20f7f2a0f60368072 AS base
ENV BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:$PATH"
# Bun, Nixpacks and Railpack come from GitHub releases; the script falls back to
# the GitHub API when github.com fails to serve them.
COPY scripts/github-release-asset.sh /usr/local/bin/github-release-asset
# The Node base image can lag behind a Debian security update by days, and the
# image scan fails on any fixed finding, so the base stage takes every update.
# The registry build cache would keep this layer until the base image changes;
# CI passes the UTC date, so the first build of a day takes that day's updates.
ARG DEBIAN_UPDATES_DAY=
RUN echo "Debian updates of ${DEBIAN_UPDATES_DAY:-the build day}" \
&& apt-get update \
&& apt-get upgrade -y --no-install-recommends \
&& apt-get install -y --no-install-recommends bash ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/* \
&& bun_arch="$(uname -m | sed 's/x86_64/x64/')" \
&& github-release-asset oven-sh/bun bun-v1.4.4 "bun-linux-$bun_arch.zip" /tmp/bun.zip \
&& unzip -q /tmp/bun.zip -d /tmp/bun \
&& install -D -m 0755 "/tmp/bun/bun-linux-$bun_arch/bun" "$BUN_INSTALL/bin/bun" \
&& rm -rf /tmp/bun /tmp/bun.zip \
&& ln -sf "$BUN_INSTALL/bin/bun" "$BUN_INSTALL/bin/bunx" \
&& npm install -g node-gyp@13.1.0
FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y python3 make g++ git python3-pip pkg-config libsecret-1-dev && rm -rf /var/lib/apt/lists/*
# Install dependencies
RUN --mount=type=cache,id=bun,target=/root/.bun/install/cache bun install --frozen-lockfile
# Deploy only the dokploy app
ENV NODE_ENV=production
RUN bun run --filter './packages/server' build
RUN bun run --filter './apps/api' build
RUN bun install --production --frozen-lockfile --linker hoisted
RUN mkdir -p /prod/api \
&& cp -R /usr/src/app/apps/api/package.json /prod/api/package.json \
&& cp -R /usr/src/app/node_modules /prod/api/node_modules \
&& mkdir -p /prod/api/packages \
&& cp -R /usr/src/app/packages/server /prod/api/packages/server \
&& rm -f /prod/api/node_modules/dokploy \
&& rm -f /prod/api/node_modules/@dokploy/api \
&& rm -f /prod/api/node_modules/@dokploy/schedules
RUN cp -R /usr/src/app/apps/api/dist /prod/api/dist
FROM base AS dokploy
WORKDIR /app
# Set production
ENV NODE_ENV=production
# Copy only the necessary files
COPY --from=build /prod/api/dist ./dist
COPY --from=build /prod/api/package.json ./package.json
COPY --from=build /prod/api/node_modules ./node_modules
COPY --from=build /prod/api/packages ./packages
ENV HOSTNAME=0.0.0.0
CMD ["bun", "run", "start"]