-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
105 lines (82 loc) · 3.46 KB
/
Dockerfile
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
98
99
100
101
102
103
104
105
# base
# ------------------------------------------------
FROM node:18-bookworm-slim as base
RUN apt-get update && apt-get install -y \
openssl \
&& rm -rf /var/lib/apt/lists/*
USER node
WORKDIR /home/node/app
COPY --chown=node:node .yarn/plugins .yarn/plugins
COPY --chown=node:node .yarn/releases .yarn/releases
COPY --chown=node:node .yarnrc.yml .
COPY --chown=node:node package.json .
COPY --chown=node:node api/package.json api/
COPY --chown=node:node web/package.json web/
COPY --chown=node:node yarn.lock .
COPY --chown=node:node .env.defaults .
RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
CI=1 yarn install
COPY --chown=node:node redwood.toml .
COPY --chown=node:node graphql.config.js .
# api build
# ------------------------------------------------
FROM base as api_build
COPY --chown=node:node api api
RUN yarn redwood build api
# web build
# ------------------------------------------------
FROM base as web_build
COPY --chown=node:node web web
RUN yarn redwood build web --no-prerender
# DB and data migrations
# ------------------------------------------------
# ideal place for `prisma migrate` and `@redwood/data-migrate`
# web prerender build
# ------------------------------------------------
# FROM api_build as web_build_with_prerender
# COPY --chown=node:node web web
# RUN yarn redwood build web
# serve api and fe
# ------------------------------------------------
FROM node:18-bookworm-slim as api_fe_serve
RUN apt-get update && apt-get install -y \
openssl \
&& rm -rf /var/lib/apt/lists/*
USER node
WORKDIR /home/node/app
COPY --chown=node:node .yarn/plugins .yarn/plugins
COPY --chown=node:node .yarn/releases .yarn/releases
COPY --chown=node:node .yarnrc.yml .
COPY --chown=node:node api/package.json api/package.json
COPY --chown=node:node web/package.json web/package.json
COPY --chown=node:node package.json .
COPY --chown=node:node yarn.lock .
RUN yarn plugin import workspace-tools
RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/home/node/.cache,uid=1000 \
CI=1 yarn workspaces focus api web --production
COPY --chown=node:node redwood.toml .
COPY --chown=node:node graphql.config.js .
COPY --chown=node:node --from=api_build /home/node/app/api/dist /home/node/app/api/dist
COPY --chown=node:node --from=api_build /home/node/app/api/db /home/node/app/api/db
COPY --chown=node:node --from=api_build /home/node/app/node_modules/.prisma /home/node/app/node_modules/.prisma
COPY --chown=node:node --from=web_build /home/node/app/web/dist /home/node/app/web/dist
ENV NODE_ENV=production
ENV PRISMA_HIDE_UPDATE_MESSAGE=true
ENV REDWOOD_ENV_BASE_URL=https://badge-app-staging.fly.dev
ENV REDWOOD_ENV_SCREENSHOT_URL=https://badge-app-staging.fly.dev
ENV RWJS_EXP_SSR_GRAPHQL_ENDPOINT=http://127.0.0.1:8910/.redwood/functions/graphql
ENV GITHUB_OAUTH_CLIENT_ID=1ca0354cfbd95b99a884
ENV GITHUB_OAUTH_SCOPES=read:user
ENV GITHUB_OAUTH_REDIRECT_URI=https://badge-app-staging.fly.dev/.redwood/functions/oauth/callback
ENV REDWOOD_ENV_CLOUDINARY_CLOUD=duh8p234y
ENV REDWOOD_ENV_CLOUDINARY_UPLOAD_LOGOS=8FCiAN_logos
ENV REDWOOD_ENV_CLOUDINARY_UPLOAD_BADGES=badges
ENV SMTP_HOST=smtp.resend.com
ENV SMTP_PORT=465
ENV SMTP_USERNAME=resend
ENV REDWOOD_ENV_API_FLASH=https://api.apiflash.com/v1/urltoimage?access_key=eadde47932454b54a1718823d2ead7cd&wait_until=page_loaded
COPY --chown=node:node .fly .fly
ENTRYPOINT ["sh"]
CMD [".fly/start.sh"]