-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgatsby-preview.dockerfile
50 lines (45 loc) · 2.3 KB
/
gatsby-preview.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
FROM amazeeio/node:14-builder as builder
# For mozjpeg to compile required stuff.
RUN apk add --no-cache autoconf automake libtool nasm
# The monorepo dance 💃
# Install dependencies for the whole monorepo because
# 1. The --ignore-workspaces flag is not implemented https://github.com/yarnpkg/yarn/issues/4099
# 2. The --focus flag is broken https://github.com/yarnpkg/yarn/issues/6715
COPY lerna.json package.json yarn.lock /app/
COPY apps /app/apps
COPY packages /app/packages
RUN set -x && \
# Avoid the target workspace dependencies to land in the root node_modules.
sed -i 's|"dependencies":|"workspaces": { "nohoist": ["**"] }, "dependencies":|g' apps/silverback-gatsby/package.json && \
# Run `yarn install` twice to workaround https://github.com/yarnpkg/yarn/issues/6988
(CYPRESS_INSTALL_BINARY=0 yarn || true) && \
# No idea how it's possible, but with `(CYPRESS_INSTALL_BINARY=0 yarn || yarn)`
# the second `yarn install` sometimes can't see the CYPRESS_INSTALL_BINARY env
# var.
(CYPRESS_INSTALL_BINARY=0 yarn) && \
# Find all linked node_modules and dereference them so that there are no broken
# symlinks in the next container. (Don't use
# `cp -rL /app/apps/silverback-gatsby /tmp/silverback-gatsby` because then it
# also dereferences node_modules/.bin/* and thus breaks them.)
cd /app/apps/silverback-gatsby/node_modules && \
for f in $(find . -maxdepth 1 -type l); do l=$(readlink -f $f) && rm $f && cp -rf $l $f; done && \
cd - && \
# Remove everything except the target workspace to reduce the layer size.
mv /app/apps/silverback-gatsby /tmp/silverback-gatsby && \
rm -rf /app
FROM amazeeio/node:14
COPY --from=builder /tmp/silverback-gatsby /app
# App env vars.
ENV ENABLE_GATSBY_REFRESH_ENDPOINT=true
ENV DRUPAL_BASE_URL=https://nginx-silverback-gatsby-development.ch.amazee.io
ENV DRUPAL_GRAHPQL_ENDPOINT=https://nginx-silverback-gatsby-development.ch.amazee.io/silverback-gatsby
ENV GATSBY_PLUGIN_BUILD_MONITOR_ENDPOINT=https://nginx-silverback-gatsby-development.ch.amazee.io/gatsby-build-monitor/set-state
ENV GATSBY_PLUGIN_BUILD_MONITOR_TOKEN=zbryaiSF9xjfNrVEu9RSqxt5QqfeQp6FJB5TKTQg950
ENV DRUPAL_PREVIEW_USER_CREDENTIALS=GatsbyPreview:GatsbyPreview
CMD [ \
"yarn", "develop", \
# This is the key thing to run Gatsby on Lagoon.
"--host", "0.0.0.0", \
# Lagoon's default port for Node.js apps.
"--port", "3000" \
]