Skip to content

Commit

Permalink
🔧 add docker for sanity v3 (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia committed Jun 6, 2023
1 parent 7bbaf21 commit ac53f90
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions sanityv3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Build
FROM node:lts-alpine AS builder

ENV NODE_OPTIONS="--max_old_space_size=8192"
RUN npm install -g pnpm@^8.5.1

WORKDIR /opt/app

RUN npm install dotenv fs

COPY ./package.json ./
COPY ./pnpm-lock.yaml ./
COPY ./tsconfig.base.json ./
COPY ./satellitesConfig.js ./
COPY ./FeatureFlags.js ./
COPY ./studio ./studio

ARG ARG_SANITY_API_TOKEN
ARG ARG_SANITY_PROJECT_ID
ARG ARG_SANITY_DATASET
ARG ARG_SANITY_PREVIEW
ARG ARG_BRANDMASTER_URL
ARG ARG_BRANDMASTER_PLUGIN
ARG ARG_FOTOWARE_CLIENT_ID
ARG ARG_FOTOWARE_TENANT_URL
ARG ARG_FOTOWARE_REDIRECT_ORIGIN
ARG ARG_FOTOWARE_AF_EXPORT_URL
ARG ARG_FOTOWARE_AF_EXPORT_KEY
ARG ARG_SCREEN9_ACCOUNT_ID
ARG ARG_SCREEN9_TOKEN

ENV SANITY_STUDIO_API_TOKEN ${ARG_SANITY_API_TOKEN}
ENV SANITY_STUDIO_API_PROJECT_ID ${ARG_SANITY_PROJECT_ID}
ENV SANITY_STUDIO_API_DATASET ${ARG_SANITY_DATASET}
ENV SANITY_STUDIO_PREVIEW_SECRET ${ARG_SANITY_PREVIEW}
ENV SANITY_STUDIO_BRANDMASTER_URL ${ARG_BRANDMASTER_URL}
ENV SANITY_STUDIO_BRANDMASTER_PLUGIN_SOURCE ${ARG_BRANDMASTER_PLUGIN}
ENV SANITY_STUDIO_FOTOWARE_CLIENT_ID ${ARG_FOTOWARE_CLIENT_ID}
ENV SANITY_STUDIO_FOTOWARE_TENANT_URL ${ARG_FOTOWARE_TENANT_URL}
ENV SANITY_STUDIO_FOTOWARE_REDIRECT_ORIGIN ${ARG_FOTOWARE_REDIRECT_ORIGIN}
ENV SANITY_STUDIO_FOTOWARE_AF_EXPORT_URL ${ARG_FOTOWARE_AF_EXPORT_URL}
ENV SANITY_STUDIO_FOTOWARE_AF_EXPORT_KEY ${ARG_FOTOWARE_AF_EXPORT_KEY}
ENV SANITY_STUDIO_SCREEN9_ACCOUNT_ID ${ARG_SCREEN9_ACCOUNT_ID}
ENV SANITY_STUDIO_SCREEN9_TOKEN ${ARG_SCREEN9_TOKEN}

RUN pnpm install
RUN pnpm studio
RUN pnpm studio build

# Run
FROM node:lts-alpine AS runner

WORKDIR /opt/app

ENV PORT 3333
ENV USER sanity
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"

RUN chown -R "$USER":"$USER" .

USER "$UID"

RUN mkdir dist

COPY --from=builder ./opt/app/studio/dist ./dist
COPY --from=builder ./opt/app/studio/server.js .

RUN npm install [email protected] [email protected]

EXPOSE "$PORT"

CMD ["npm", "start"]

0 comments on commit ac53f90

Please sign in to comment.