Skip to content

Commit e956d5d

Browse files
siddharthvpsupertassu
authored andcommitted
Remove manual build step
Run `npm run build` while building the container. The compiled artifact is removed from the checked-in code, and added to .gitignore. Bug: T396991 Change-Id: I5dbb1da8561ef44384afe84319eb6dfb168123f8
1 parent 17d9fc8 commit e956d5d

File tree

6 files changed

+32
-464
lines changed

6 files changed

+32
-464
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Dockerfile
2-
docker-compose.yml
2+
docker-compose.yml
3+
node_modules

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ terraform.tfstate*
2020
.terraform*
2121
tofu/kube.config
2222
ansible/collections/*
23+
quarry/web/static/templates/compiled.js

Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,22 @@ RUN pip install --break-system-packages --upgrade pip==24.0 wheel && \
1717
pip install --break-system-packages -r requirements.txt
1818

1919
# Copy app code
20-
USER quarry
2120
COPY . /app
2221

22+
# Build JS assets
23+
RUN apt-get update && \
24+
apt-get install -y nodejs npm && \
25+
NODE_ENV=production npm ci && \
26+
npm run build && \
27+
# Once the build is run, dependencies are no longer needed, delete them
28+
# to keep image small
29+
rm -rf node_modules && \
30+
apt-get remove -y nodejs npm && \
31+
apt-get autoremove -y && \
32+
rm -rf /var/lib/apt/lists/*
33+
34+
USER quarry
35+
2336
# Expose port for web server
2437
EXPOSE 5000
2538

0 commit comments

Comments
 (0)