|
|
@ -1,29 +1,31 @@ |
|
|
|
# syntax=docker/dockerfile:1 |
|
|
|
# syntax=docker/dockerfile:1.5 |
|
|
|
|
|
|
|
# Use Buildx cross-compilation |
|
|
|
|
|
|
|
|
|
|
|
########### |
|
|
|
########### |
|
|
|
# Litestream Builder |
|
|
|
# Litestream Builder |
|
|
|
########### |
|
|
|
########### |
|
|
|
FROM golang:alpine3.19 as lt-builder |
|
|
|
FROM --platform=$BUILDPLATFORM golang:alpine3.19 as lt-builder |
|
|
|
|
|
|
|
|
|
|
|
WORKDIR /usr/src/ |
|
|
|
WORKDIR /usr/src/ |
|
|
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache git make musl-dev gcc |
|
|
|
# Use build platform-specific tools |
|
|
|
|
|
|
|
RUN apk --no-cache add git make musl-dev gcc |
|
|
|
|
|
|
|
|
|
|
|
# build litestream |
|
|
|
# Build litestream for target platform |
|
|
|
RUN git clone https://github.com/benbjohnson/litestream.git litestream |
|
|
|
RUN git clone https://github.com/benbjohnson/litestream.git litestream \ |
|
|
|
RUN cd litestream && go install ./cmd/litestream |
|
|
|
&& cd litestream && GOARCH=$(go env GOARCH) GOOS=$(go env GOOS) go install ./cmd/litestream \ |
|
|
|
RUN cp $GOPATH/bin/litestream /usr/src/lt |
|
|
|
&& cp $GOPATH/bin/litestream /usr/src/lt |
|
|
|
|
|
|
|
|
|
|
|
########### |
|
|
|
########### |
|
|
|
# Builder |
|
|
|
# Builder |
|
|
|
########### |
|
|
|
########### |
|
|
|
FROM node:18.19.1-alpine as builder |
|
|
|
FROM --platform=$BUILDPLATFORM node:18.19.1-alpine as builder |
|
|
|
WORKDIR /usr/src/app |
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
|
|
|
|
|
|
|
# install node-gyp dependencies |
|
|
|
# Install node-gyp dependencies |
|
|
|
RUN apk add --no-cache python3 make g++ |
|
|
|
RUN apk add --no-cache python3 make g++ |
|
|
|
|
|
|
|
|
|
|
|
# install pnpm |
|
|
|
# Install pnpm |
|
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate |
|
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate |
|
|
|
|
|
|
|
|
|
|
|
# Copy application dependency manifests to the container image. |
|
|
|
# Copy application dependency manifests to the container image. |
|
|
@ -33,22 +35,33 @@ COPY --link ./docker/start-litestream.sh /usr/src/appEntry/start.sh |
|
|
|
COPY --link src/public/ ./docker/public/ |
|
|
|
COPY --link src/public/ ./docker/public/ |
|
|
|
COPY --link ./docker/nc-gui/ ./docker/nc-gui/ |
|
|
|
COPY --link ./docker/nc-gui/ ./docker/nc-gui/ |
|
|
|
|
|
|
|
|
|
|
|
# for pnpm to generate a flat node_modules without symlinks |
|
|
|
# For pnpm to generate a flat node_modules without symlinks |
|
|
|
# so that modclean could work as expected |
|
|
|
# So that modclean works as expected |
|
|
|
RUN echo "node-linker=hoisted" > .npmrc |
|
|
|
RUN echo "node-linker=hoisted" > .npmrc |
|
|
|
|
|
|
|
|
|
|
|
# install production dependencies, |
|
|
|
# Install production dependencies, reduce node_module size with modclean |
|
|
|
# reduce node_module size with modclean & removing sqlite deps, |
|
|
|
# Removing sqlite deps and add execute permission to start.sh |
|
|
|
# and add execute permission to start.sh |
|
|
|
|
|
|
|
RUN pnpm install --prod --shamefully-hoist \ |
|
|
|
RUN pnpm install --prod --shamefully-hoist \ |
|
|
|
&& pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,@azure/msal-node/dist/**" --run \ |
|
|
|
&& pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,@azure/msal-node/dist/**" --run \ |
|
|
|
&& rm -rf ./node_modules/sqlite3/deps \ |
|
|
|
&& rm -rf ./node_modules/sqlite3/deps \ |
|
|
|
&& chmod +x /usr/src/appEntry/start.sh |
|
|
|
&& chmod +x /usr/src/appEntry/start.sh |
|
|
|
|
|
|
|
# && (pnpm exec prebuild-install -- --platform=$TARGETPLATFORM --arch=$TARGETARCH -r napi || echo "Prebuilt binary not available") \ |
|
|
|
|
|
|
|
# && npm install sqlite3 --target_arch=$BUILDARCH --target_platform=$BUILDOS --legacy-peer-deps \ |
|
|
|
|
|
|
|
|
|
|
|
########## |
|
|
|
|
|
|
|
|
|
|
|
############ |
|
|
|
|
|
|
|
## Sqlite3 Builder |
|
|
|
|
|
|
|
############ |
|
|
|
|
|
|
|
FROM node:18.19.1-alpine as sqlite-builder |
|
|
|
|
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Install sqlite3 for the target platform to copy to the final image |
|
|
|
|
|
|
|
RUN npm init -y && npm install sqlite3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########### |
|
|
|
# Runner |
|
|
|
# Runner |
|
|
|
########## |
|
|
|
########### |
|
|
|
FROM alpine:3.19 |
|
|
|
FROM --platform=$TARGETPLATFORM alpine:3.19 |
|
|
|
WORKDIR /usr/src/app |
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
|
|
|
|
|
|
|
ENV LITESTREAM_S3_SKIP_VERIFY=false \ |
|
|
|
ENV LITESTREAM_S3_SKIP_VERIFY=false \ |
|
|
@ -61,16 +74,15 @@ ENV LITESTREAM_S3_SKIP_VERIFY=false \ |
|
|
|
NODE_ENV=production \ |
|
|
|
NODE_ENV=production \ |
|
|
|
PORT=8080 |
|
|
|
PORT=8080 |
|
|
|
|
|
|
|
|
|
|
|
RUN apk add --update --no-cache \ |
|
|
|
RUN apk add --update --no-cache dasel dumb-init nodejs |
|
|
|
dasel \ |
|
|
|
|
|
|
|
dumb-init \ |
|
|
|
|
|
|
|
nodejs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Copy litestream binary and config file |
|
|
|
# Copy litestream binary and config file |
|
|
|
COPY --link --from=lt-builder /usr/src/lt /usr/local/bin/litestream |
|
|
|
COPY --link --from=lt-builder /usr/src/lt /usr/local/bin/litestream |
|
|
|
COPY --link ./docker/litestream.yml /etc/litestream.yml |
|
|
|
COPY --link ./docker/litestream.yml /etc/litestream.yml |
|
|
|
|
|
|
|
|
|
|
|
# Copy production code & main entry file |
|
|
|
# Copy production code & main entry file |
|
|
|
COPY --link --from=builder /usr/src/app/ /usr/src/app/ |
|
|
|
COPY --link --from=builder /usr/src/app/ /usr/src/app/ |
|
|
|
|
|
|
|
COPY --link --from=sqlite-builder /usr/src/app/node_modules/sqlite3/ /usr/src/app/node_modules/sqlite3/ |
|
|
|
COPY --link --from=builder /usr/src/appEntry/ /usr/src/appEntry/ |
|
|
|
COPY --link --from=builder /usr/src/appEntry/ /usr/src/appEntry/ |
|
|
|
|
|
|
|
|
|
|
|
EXPOSE 8080 |
|
|
|
EXPOSE 8080 |
|
|
|