Skip to content

Commit 42d326f

Browse files
committed
Adjust docker image for #3415
``` yarn gel:gen ``` now runs the standard ts compilation which generates the js files in dist/ Previously the gel user did not have permission to this dir, as we only applied the owner change to src/ (old line 87). Now we'll set the current user as "gel" and copy in all files as that owner. This is more idiomatic for Docker.
1 parent 1b9689b commit 42d326f

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

Dockerfile

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ corepack enable
5959
EOF
6060
# endregion
6161

62-
WORKDIR /source
63-
6462
ENV NODE_ENV=development \
6563
# Ignore creds during this build process
6664
GEL_SERVER_SECURITY=insecure_dev_mode \
@@ -71,34 +69,32 @@ ENV NODE_ENV=development \
7169
# Don't flood log with cache debug messages
7270
VERBOSE_YARN_LOG=discard
7371

74-
# Install dependencies (in separate docker layer from app code)
75-
COPY .yarn .yarn
76-
COPY package.json yarn.lock .yarnrc.yml ./
77-
RUN yarn install --immutable
78-
79-
# Copy in application code
80-
COPY ./dbschema /dbschema
81-
COPY . .
82-
83-
# region Generate Gel TS/JS files
84-
RUN <<EOF
85-
set -e
86-
87-
chown -R gel:gel /dbschema src
88-
8972
# Run the migrations in a single transaction, so we don't hit a CLI timeout
90-
sed -i 's|schema-dir=/dbschema|schema-dir=/dbschema --single-transaction|' /usr/local/bin/docker-entrypoint-funcs.sh
73+
RUN sed -i 's|schema-dir=/dbschema|schema-dir=/dbschema --single-transaction|' /usr/local/bin/docker-entrypoint-funcs.sh
9174

9275
# Hook `yarn gel:gen` into gel bootstrap.
9376
# This allows it to be ran in parallel to the db server running without a daemon
77+
RUN <<EOF
78+
set -e
9479
mkdir -p /gel-bootstrap-late.d
9580
printf "#!/usr/bin/env bash\ncd /source \nyarn gel:gen\n" > /gel-bootstrap-late.d/01-generate-js.sh
9681
chmod +x /gel-bootstrap-late.d/01-generate-js.sh
82+
EOF
83+
84+
USER gel
85+
WORKDIR /source
86+
87+
# Install dependencies (in separate docker layer from app code)
88+
COPY --chown=gel:gel .yarn .yarn
89+
COPY --chown=gel:gel package.json yarn.lock .yarnrc.yml ./
90+
RUN yarn install --immutable
91+
92+
# Copy in application code
93+
COPY --chown=gel:gel ./dbschema /dbschema
94+
COPY --chown=gel:gel . .
9795

9896
# Bootstrap the db to apply migrations and then generate the TS/JS from that.
99-
/usr/local/bin/docker-entrypoint.sh server
100-
EOF
101-
# endregion
97+
RUN /usr/local/bin/docker-entrypoint.sh server
10298

10399
# Build server
104100
RUN yarn build

0 commit comments

Comments
 (0)