forked from slopus/happy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.webapp
More file actions
97 lines (80 loc) · 2.72 KB
/
Dockerfile.webapp
File metadata and controls
97 lines (80 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Stage 1: install dependencies with workspace context
FROM node:20-alpine AS deps
WORKDIR /repo
COPY package.json yarn.lock ./
COPY scripts ./scripts
RUN mkdir -p packages/happy-app packages/happy-server packages/happy-cli packages/happy-wire
COPY packages/happy-app/package.json packages/happy-app/
COPY packages/happy-server/package.json packages/happy-server/
COPY packages/happy-cli/package.json packages/happy-cli/
COPY packages/happy-wire/package.json packages/happy-wire/
# Workspace postinstall requirements
COPY packages/happy-app/patches packages/happy-app/patches
COPY packages/happy-server/prisma packages/happy-server/prisma
COPY packages/happy-cli/scripts packages/happy-cli/scripts
COPY packages/happy-cli/tools packages/happy-cli/tools
RUN SKIP_HAPPY_WIRE_BUILD=1 yarn install --frozen-lockfile --ignore-engines
# Stage 2: build the web app
FROM deps AS builder
ARG POSTHOG_API_KEY=""
ARG REVENUE_CAT_STRIPE=""
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
COPY packages/happy-wire ./packages/happy-wire
COPY packages/happy-app ./packages/happy-app
RUN yarn workspace @slopus/happy-wire build
RUN yarn workspace happy-app 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;"]