|
@@ -3,21 +3,39 @@ ARG ALPINE_VERSION="3.18"
|
|
|
|
|
|
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS node_base
|
|
|
|
|
|
+# ---- BUILDER BASE ----
|
|
|
FROM node_base AS builder_base
|
|
|
|
|
|
RUN npm install pnpm -g
|
|
|
+RUN apk add curl
|
|
|
|
|
|
+# ---- RUNNER BASE ----
|
|
|
FROM node_base AS runner_base
|
|
|
|
|
|
-# Install docker
|
|
|
-RUN apk upgrade --update-cache --available && \
|
|
|
- apk add openssl git docker docker-cli-compose curl && \
|
|
|
- rm -rf /var/cache/apk/*
|
|
|
+RUN apk add curl openssl git && rm -rf /var/cache/apk/*
|
|
|
|
|
|
+ARG NODE_ENV="production"
|
|
|
+
|
|
|
+# ---- BUILDER ----
|
|
|
FROM builder_base AS builder
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
+ARG TARGETARCH
|
|
|
+ENV TARGETARCH=${TARGETARCH}
|
|
|
+
|
|
|
+RUN echo "Building for ${TARGETARCH}"
|
|
|
+
|
|
|
+RUN if [ "${TARGETARCH}" = "arm64" ]; then \
|
|
|
+ curl -L -o docker-binary "https://github.com/docker/compose/releases/download/v2.23.1/docker-compose-linux-aarch64"; \
|
|
|
+ elif [ "${TARGETARCH}" = "amd64" ]; then \
|
|
|
+ curl -L -o docker-binary "https://github.com/docker/compose/releases/download/v2.23.1/docker-compose-linux-x86_64"; \
|
|
|
+ else \
|
|
|
+ echo "Unsupported architecture"; \
|
|
|
+ fi
|
|
|
+
|
|
|
+RUN chmod +x docker-binary
|
|
|
+
|
|
|
COPY ./pnpm-lock.yaml ./
|
|
|
COPY ./pnpm-workspace.yaml ./
|
|
|
COPY ./patches ./patches
|
|
@@ -34,6 +52,7 @@ COPY ./packages/worker/assets ./packages/worker/assets
|
|
|
|
|
|
RUN pnpm -r build --filter @runtipi/worker
|
|
|
|
|
|
+# ---- RUNNER ----
|
|
|
FROM runner_base AS app
|
|
|
|
|
|
WORKDIR /app
|
|
@@ -42,6 +61,7 @@ ENV NODE_ENV=production
|
|
|
|
|
|
COPY --from=builder /app/packages/worker/dist .
|
|
|
COPY --from=builder /app/packages/worker/assets ./assets
|
|
|
+COPY --from=builder /app/docker-binary /usr/local/bin/docker-compose
|
|
|
|
|
|
CMD ["node", "index.js", "start"]
|
|
|
|