-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
ce7020d
commit ed39012
Showing
6 changed files
with
143 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,77 @@ | ||
ARG ARG_DYNATRACE_IMAGE='node:lts-alpine' | ||
FROM ${ARG_DYNATRACE_IMAGE} AS dynatrace | ||
ARG ARG_DYNATRACE_IMAGE='node:16-alpine' | ||
|
||
FROM node:lts-alpine AS builder | ||
FROM ${ARG_DYNATRACE_IMAGE} AS dynatrace | ||
|
||
RUN npm install -g pnpm@^7.2.1 | ||
FROM node:16-alpine AS deps | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
WORKDIR /opt/app | ||
COPY package.json pnpm-lock.yaml ./ | ||
COPY web/package.json web/pnpm-lock.yaml web/ | ||
|
||
# Should consider using pnpm fetch | ||
COPY ./package.json ./ | ||
COPY ./pnpm-lock.yaml ./ | ||
COPY ./tsconfig.base.json ./ | ||
COPY ./satellitesConfig.js ./ | ||
COPY ./FeatureFlags.js ./ | ||
COPY ./pnpm-workspace.yaml ./ | ||
COPY ./.npmrc ./ | ||
COPY ./web ./web | ||
RUN \ | ||
if [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm m i --frozen-lockfile;\ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
# Replace workspace:* with the actual versions | Load css from public folder atm | ||
# RUN version=$(jq --raw-output .version ./legacy/css/package.json); \ | ||
# jq --arg legacy_css "$version" '.dependencies["@equinor/energyvision-legacy-css"] = $legacy_css' \ | ||
# ./web/package.json | sponge ./web/package.json | ||
FROM node:16-alpine AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY --from=deps /app/web/node_modules ./web/node_modules | ||
COPY . . | ||
|
||
ARG ARG_SANITY_PROJECT_ID | ||
ARG ARG_SANITY_DATASET | ||
ARG ARG_ALGOLIA_APP_ID | ||
ARG ARG_ALGOLIA_SEARCH_API_KEY | ||
|
||
ENV NEXT_PUBLIC_SANITY_PROJECT_ID ${ARG_SANITY_PROJECT_ID} | ||
ENV NEXT_PUBLIC_SANITY_DATASET ${ARG_SANITY_DATASET} | ||
ENV NEXT_PUBLIC_ALGOLIA_APP_ID ${ARG_ALGOLIA_APP_ID} | ||
ENV NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY ${ARG_ALGOLIA_SEARCH_API_KEY} | ||
ARG ARG_SANITY_PROJECT_ID | ||
ENV NEXT_PUBLIC_SANITY_PROJECT_ID ${ARG_SANITY_PROJECT_ID} | ||
|
||
#RUN pnpm install --recursive --frozen-lockfile | ||
RUN pnpm web install --frozen-lockfile | ||
RUN pnpm web build | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
FROM node:lts-alpine as runner | ||
RUN cd web && yarn build | ||
|
||
RUN npm install -g pnpm@^7.2.1 | ||
|
||
WORKDIR /opt/app | ||
# Production image, copy all the files and run next | ||
FROM node:16-alpine AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
ENV PORT 3000 | ||
ENV USER nextjs | ||
ENV UID 12345 | ||
ENV GID 23456 | ||
|
||
RUN addgroup -S "$USER" && \ | ||
adduser -S \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/opt/app" \ | ||
--ingroup "$USER" \ | ||
--no-create-home \ | ||
--uid "$UID" \ | ||
"$USER" | ||
|
||
COPY --from=builder /opt/app/web/.next ./web/.next | ||
COPY --from=builder /opt/app/web/next.config.mjs ./web | ||
COPY --from=builder /opt/app/web/securityHeaders.mjs ./web | ||
COPY --from=builder /opt/app/web/package.json ./web | ||
COPY --from=builder /opt/app/web/node_modules ./web/node_modules | ||
COPY --from=builder /opt/app/web/pnpm-lock.yaml ./web | ||
COPY --from=builder /opt/app/web/languages.js ./web | ||
COPY --from=builder /opt/app/pnpm-lock.yaml ./ | ||
COPY --from=builder /opt/app/web/public ./web/public | ||
COPY --from=builder /opt/app/package.json ./ | ||
COPY --from=builder /opt/app/satellitesConfig.js ./ | ||
COPY --from=builder /opt/app/pnpm-workspace.yaml ./ | ||
COPY --from=builder /opt/app/.npmrc ./ | ||
|
||
RUN chown -R "$USER":"$USER" . | ||
USER "$UID" | ||
|
||
ARG ARG_SANITY_PROJECT_ID | ||
ARG ARG_ENV | ||
ENV ENV ${ARG_ENV} | ||
ARG ARG_SANITY_DATASET | ||
ENV NEXT_PUBLIC_SANITY_PROJECT_ID ${ARG_SANITY_PROJECT_ID} | ||
ENV NEXT_PUBLIC_SANITY_DATASET ${ARG_SANITY_DATASET} | ||
|
||
ARG ARG_SANITY_API_TOKEN | ||
ARG ARG_SANITY_PREVIEW_SECRET | ||
|
||
ENV SANITY_API_TOKEN ${ARG_SANITY_API_TOKEN} | ||
ENV SANITY_PREVIEW_SECRET ${ARG_SANITY_PREVIEW_SECRET} | ||
|
||
ARG ARG_SANITY_PROJECT_ID | ||
ENV NEXT_PUBLIC_SANITY_PROJECT_ID ${ARG_SANITY_PROJECT_ID} | ||
ARG ARG_ALGOLIA_APP_ID | ||
ARG ARG_ALGOLIA_SEARCH_API_KEY | ||
ARG ARG_ALGOLIA_SEARCH_API_SERVER_KEY | ||
ENV NEXT_PUBLIC_ALGOLIA_APP_ID ${ARG_ALGOLIA_APP_ID} | ||
ARG ARG_ALGOLIA_SEARCH_API_KEY | ||
ENV NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY ${ARG_ALGOLIA_SEARCH_API_KEY} | ||
ARG ARG_ALGOLIA_SEARCH_API_SERVER_KEY | ||
ENV ALGOLIA_SEARCH_API_SERVER_KEY ${ARG_ALGOLIA_SEARCH_API_SERVER_KEY} | ||
|
||
ARG ARG_ENV | ||
ENV ENV ${ARG_ENV} | ||
ENV PORT 3000 | ||
ENV USER nextjs | ||
ENV UID 12345 | ||
# https://nextjs.org/telemetry | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup -S "$USER" | ||
RUN adduser -S --uid "$UID" "$USER" | ||
|
||
COPY --from=builder /app/web/public ./public | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown="$USER":"$USER" /app/web/.next/standalone . | ||
COPY --from=builder --chown="$USER":"$USER" /app/web/.next/static ./.next/static | ||
|
||
USER "$UID" | ||
|
||
# Copy dynatrace or "empty" | ||
COPY --from=dynatrace / / | ||
ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so | ||
ENV DT_TAGS=EQUINORCOM\ ENVIRONMENT=${ARG_ENV}\ DT_PROCESS_GROUP=${ARG_SANITY_DATASET} | ||
|
||
EXPOSE "$PORT" | ||
CMD ["pnpm", "web", "start"] | ||
|
||
CMD ["node", "server.js"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.