98e40dac97
CLI Smoke Test / smoke-test-linux (20) (push) Waiting to run
CLI Smoke Test / smoke-test-linux (24) (push) Waiting to run
CLI Smoke Test / smoke-test-windows (20) (push) Waiting to run
CLI Smoke Test / smoke-test-windows (24) (push) Waiting to run
Expo App TypeScript typecheck / typecheck (push) Waiting to run
108 lines
3.0 KiB
Docker
108 lines
3.0 KiB
Docker
# Stage 1: install dependencies with workspace context
|
|
FROM node:20-alpine AS deps
|
|
|
|
RUN corepack enable && corepack prepare pnpm@10.11.0 --activate
|
|
|
|
WORKDIR /repo
|
|
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
|
COPY scripts ./scripts
|
|
COPY patches ./patches
|
|
|
|
RUN mkdir -p packages/happy-app packages/happy-wire
|
|
|
|
COPY packages/happy-app/package.json packages/happy-app/
|
|
COPY packages/happy-wire/package.json packages/happy-wire/
|
|
|
|
# Workspace postinstall requirements
|
|
COPY packages/happy-app/patches packages/happy-app/patches
|
|
|
|
# The repo defaults to a hoisted linker for local development. Keep this Docker
|
|
# install isolated so unrelated workspace native deps do not get built here.
|
|
RUN SKIP_HAPPY_WIRE_BUILD=1 pnpm install \
|
|
--frozen-lockfile \
|
|
--filter happy-app... \
|
|
--config.node-linker=isolated \
|
|
--config.shamefully-hoist=false
|
|
|
|
# Stage 2: build the web app
|
|
FROM deps AS builder
|
|
|
|
ARG POSTHOG_API_KEY=""
|
|
ARG REVENUE_CAT_STRIPE=""
|
|
ARG HAPPY_SERVER_URL=""
|
|
ARG HAPPY_BUILD_COMMIT_SHA=""
|
|
ARG HAPPY_BUILD_COMMIT_TIMESTAMP=""
|
|
|
|
ENV NODE_ENV=production
|
|
ENV APP_ENV=production
|
|
ENV EXPO_PUBLIC_POSTHOG_API_KEY=$POSTHOG_API_KEY
|
|
ENV EXPO_PUBLIC_REVENUE_CAT_STRIPE=$REVENUE_CAT_STRIPE
|
|
ENV EXPO_PUBLIC_HAPPY_SERVER_URL=$HAPPY_SERVER_URL
|
|
ENV HAPPY_BUILD_COMMIT_SHA=$HAPPY_BUILD_COMMIT_SHA
|
|
ENV HAPPY_BUILD_COMMIT_TIMESTAMP=$HAPPY_BUILD_COMMIT_TIMESTAMP
|
|
|
|
COPY packages/happy-wire ./packages/happy-wire
|
|
COPY packages/happy-app ./packages/happy-app
|
|
|
|
RUN pnpm --filter @slopus/happy-wire build
|
|
RUN pnpm --filter happy-app exec expo export --platform web --output-dir dist
|
|
|
|
# Stage 3: runtime with Nginx
|
|
FROM nginx:alpine AS runner
|
|
|
|
COPY --from=builder /repo/packages/happy-app/dist /usr/share/nginx/html
|
|
|
|
# Remove default nginx configuration
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
|
|
# Create custom nginx configuration directly in the Dockerfile
|
|
RUN echo 'server { \
|
|
listen 80; \
|
|
\
|
|
location /_expo/ { \
|
|
root /usr/share/nginx/html; \
|
|
try_files $uri =404; \
|
|
} \
|
|
\
|
|
location /assets/ { \
|
|
root /usr/share/nginx/html; \
|
|
try_files $uri =404; \
|
|
} \
|
|
\
|
|
location /.well-known/ { \
|
|
root /usr/share/nginx/html; \
|
|
try_files $uri =404; \
|
|
} \
|
|
\
|
|
location / { \
|
|
root /usr/share/nginx/html; \
|
|
index index.html index.htm; \
|
|
try_files $uri $uri.html $uri/index.html $uri/index.htm $uri/ /index.html /index.htm =404; \
|
|
} \
|
|
\
|
|
error_page 500 502 503 504 /50x.html; \
|
|
location = /50x.html { \
|
|
root /usr/share/nginx/html; \
|
|
try_files $uri @redirect_to_index; \
|
|
internal; \
|
|
} \
|
|
\
|
|
error_page 404 = @handle_404; \
|
|
\
|
|
location @handle_404 { \
|
|
root /usr/share/nginx/html; \
|
|
try_files /404.html @redirect_to_index; \
|
|
internal; \
|
|
} \
|
|
\
|
|
location @redirect_to_index { \
|
|
return 302 /; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose the standard nginx port
|
|
EXPOSE 80
|
|
|
|
# Nginx starts automatically in the foreground with CMD ["nginx", "-g", "daemon off;"]
|