Skip to content

Commit e004223

Browse files
authored
feat(front): enable writable root FS and live reload for front (#330)
## 📝 Description These changes improve the local development experience when running the cluster locally by enabling file syncing and automatic server restarts. They address local compatibility issues and allow runtime file writes inside pods still running under MIX_ENV=prod. - Replaced custom Node Dockerfile stage with node:16-alpine to fix local build issues. - Added `entr` for watching file changes during development. - Changed CMD to restart Phoenix server using `entr` on source file updates. - Made `readOnlyRootFilesystem` configurable based on the new flag. ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 31df384 commit e004223

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

front/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,26 @@ RUN mix sentry_recompile && mix compile --warnings-as-errors
4545
# -- elixir stage
4646

4747
# -- node stage
48-
FROM base AS node
49-
WORKDIR /node
50-
COPY front/assets/package.json front/assets/package-lock.json ./
51-
RUN npm install
48+
FROM node:16-alpine as node
5249
WORKDIR /assets
53-
COPY front/assets /assets
54-
RUN mv /node/node_modules /assets/node_modules
50+
COPY front/assets/package.json front/assets/package-lock.json ./
51+
RUN npm set progress=false && npm install
52+
COPY front/assets ./
5553
# -- node stage
5654

5755
# -- dev stage - for local development
5856
FROM elixir AS dev
5957
WORKDIR /app
6058
RUN apk update \
61-
&& apk add --no-cache chromium-chromedriver inotify-tools bash gnupg
59+
&& apk add --no-cache chromium-chromedriver inotify-tools bash gnupg entr
6260

6361
COPY --from=elixir /elixir ./
6462
COPY --from=node /assets ./assets
6563
WORKDIR /app/assets
6664
RUN node build.js
6765
WORKDIR /app
6866

69-
CMD [ "/bin/ash", "-c \"while sleep 1000; do :; done\"" ]
67+
CMD ["sh", "-c", "find lib config | entr -n -r mix phx.server"]
7068
# -- dev stage
7169

7270
# -- builder stage - build artifacts are created here

front/helm/templates/job-page.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spec:
6666
securityContext:
6767
privileged: false
6868
allowPrivilegeEscalation: false
69-
readOnlyRootFilesystem: true
69+
readOnlyRootFilesystem: {{ not .Values.global.development.writableRootFilesystem | default true }}
7070
capabilities:
7171
drop:
7272
- ALL

front/helm/templates/project-page.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spec:
9292
securityContext:
9393
privileged: false
9494
allowPrivilegeEscalation: false
95-
readOnlyRootFilesystem: true
95+
readOnlyRootFilesystem: {{ not .Values.global.development.writableRootFilesystem | default true }}
9696
capabilities:
9797
drop:
9898
- ALL
@@ -200,6 +200,7 @@ spec:
200200
port: http-port
201201
initialDelaySeconds: 30
202202
periodSeconds: 10
203+
failureThreshold: 3
203204
readinessProbe:
204205
httpGet:
205206
path: /is_alive

front/helm/templates/ui-cache-reactor.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
securityContext:
4747
privileged: false
4848
allowPrivilegeEscalation: false
49-
readOnlyRootFilesystem: true
49+
readOnlyRootFilesystem: {{ not .Values.global.development.writableRootFilesystem | default true }}
5050
capabilities:
5151
drop:
5252
- ALL
@@ -154,13 +154,6 @@ spec:
154154
path: /is_alive
155155
port: http-port
156156
periodSeconds: 2
157-
securityContext:
158-
privileged: false
159-
allowPrivilegeEscalation: false
160-
readOnlyRootFilesystem: true
161-
capabilities:
162-
drop:
163-
- ALL
164157

165158
{{- if .Values.cacheReactor.resources }}
166159
resources:

helm-chart/values.yaml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ global:
22
# Edition of Semaphore to install (ce or ee)
33
edition: "ce"
44

5+
development:
6+
#
7+
# When true, mounts a writable root filesystem in containers
8+
# to support local development tools.
9+
#
10+
writableRootFilesystem: false
11+
512
domain:
613
ip: ""
714
name: ""

0 commit comments

Comments
 (0)