2023-01-17 13:37:07 +03:00
|
|
|
FROM docker.io/library/node:lts-alpine AS base
|
|
|
|
|
|
|
|
# Prepare work directory
|
|
|
|
WORKDIR /elk
|
|
|
|
|
|
|
|
FROM base AS builder
|
|
|
|
|
2023-01-17 16:04:53 +03:00
|
|
|
# Prepare pnpm https://pnpm.io/installation#using-corepack
|
|
|
|
RUN corepack enable
|
2023-01-17 13:37:07 +03:00
|
|
|
|
|
|
|
# Prepare deps
|
|
|
|
RUN apk update
|
|
|
|
RUN apk add git --no-cache
|
|
|
|
|
|
|
|
# Prepare build deps ( ignore postinstall scripts for now )
|
|
|
|
COPY package.json ./
|
|
|
|
COPY pnpm-lock.yaml ./
|
|
|
|
COPY patches ./patches
|
|
|
|
RUN pnpm i --frozen-lockfile --ignore-scripts
|
|
|
|
|
|
|
|
# Copy all source files
|
|
|
|
COPY . ./
|
|
|
|
|
|
|
|
# Run full install with every postinstall script ( This needs project file )
|
|
|
|
RUN pnpm i --frozen-lockfile
|
|
|
|
|
|
|
|
# Build
|
|
|
|
RUN pnpm build
|
|
|
|
|
|
|
|
FROM base AS runner
|
|
|
|
|
2023-01-22 10:18:50 +03:00
|
|
|
ARG UID=911
|
|
|
|
ARG GID=911
|
|
|
|
|
|
|
|
# Create a dedicated user and group
|
|
|
|
RUN set -eux; \
|
2023-02-23 16:27:50 +03:00
|
|
|
addgroup -g $GID elk; \
|
|
|
|
adduser -u $UID -D -G elk elk;
|
2023-01-22 10:18:50 +03:00
|
|
|
|
|
|
|
USER elk
|
|
|
|
|
2023-01-17 13:37:07 +03:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
|
|
|
COPY --from=builder /elk/.output ./.output
|
|
|
|
|
|
|
|
EXPOSE 5314/tcp
|
|
|
|
|
|
|
|
ENV PORT=5314
|
|
|
|
|
|
|
|
# Specify container only environment variables ( can be overwritten by runtime env )
|
|
|
|
ENV NUXT_STORAGE_FS_BASE='/elk/data'
|
|
|
|
|
|
|
|
# Persistent storage data
|
|
|
|
VOLUME [ "/elk/data" ]
|
|
|
|
|
|
|
|
CMD ["node", ".output/server/index.mjs"]
|