Skip to content

Commit 8ed8ded

Browse files
committed
Refactor: migrate container build to multi-stage Dockerfile with secret mounts
1 parent 164d4f2 commit 8ed8ded

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

.github/workflows/container-publish.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,6 @@ jobs:
3030
username: ${{ github.actor }}
3131
password: ${{ secrets.GITHUB_TOKEN }}
3232

33-
- name: Start Wolfram Engine Container
34-
run: |
35-
docker run -d --name wolfram \
36-
-v $GITHUB_WORKSPACE:/workspace \
37-
-w /workspace \
38-
wolframresearch/wolframengine:14.2 tail -f /dev/null
39-
40-
- name: Fix permissions for /workspace directory at host level
41-
run: |
42-
sudo chmod -R 777 $GITHUB_WORKSPACE
43-
44-
- name: Install ffmpeg inside Wolfram container
45-
run: |
46-
docker exec --user root wolfram bash -c "apt-get update && apt-get install -y ffmpeg"
47-
48-
- name: Fetch all dependencies inside Wolfram container
49-
run: |
50-
docker exec -e WOLFRAMSCRIPT_ENTITLEMENTID=${{ secrets.WOLFRAM_LICENSE_ENTITLEMENT_ID }} wolfram \
51-
wolframscript -script ./Scripts/update.wls
52-
5333
- name: Extract Docker metadata
5434
id: meta
5535
uses: docker/metadata-action@v5
@@ -62,6 +42,8 @@ jobs:
6242
with:
6343
context: .
6444
file: "./container/Containerfile"
45+
secrets: |
46+
"wolfram_license=${{ secrets.WOLFRAM_LICENSE_ENTITLEMENT_ID }}"
6547
tags: ${{ steps.meta.outputs.tags }}
6648
labels: ${{ steps.meta.outputs.labels }}
6749
push: true

container/Containerfile

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
1-
FROM docker.io/wolframresearch/wolframengine
1+
# syntax=docker/dockerfile:1
2+
FROM docker.io/wolframresearch/wolframengine AS deps
3+
4+
RUN apt-get update && apt-get install -y ffmpeg
5+
6+
COPY Scripts/update.wls /workspace/Scripts/update.wls
7+
COPY Common/ /workspace/Common/
8+
9+
WORKDIR /workspace
10+
11+
RUN --mount=type=secret,id=wolfram_license,env=WOLFRAMSCRIPT_ENTITLEMENTID,required=true wolframscript -script Scripts/update.wls
12+
13+
14+
FROM wolframresearch/wolframengine:14.2 AS final
215

316
USER root
417

518
RUN useradd -m wljs
619

720
ENV DEBIAN_FRONTEND=noninteractive
821

22+
COPY --from=deps /workspace/wl_packages /wljs/wl_packages
23+
COPY --from=deps /workspace/wljs_packages /wljs/wljs_packages
24+
25+
COPY ./ /wljs/
26+
COPY container/run.sh /usr/local/bin/run.sh
27+
28+
COPY container/wljs-routes /etc/nginx/sites-available/default
29+
COPY container/proxy-snippet.conf /etc/nginx/snippets/proxy.conf
30+
931
RUN apt-get update && apt-get install -y \
1032
git \
1133
nginx \
1234
expect \
1335
curl \
36+
ffmpeg \
1437
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
1538
&& apt-get install -y nodejs \
1639
&& apt-get clean \
17-
&& rm -rf /var/lib/apt/lists/*
18-
19-
COPY container/wljs-routes /etc/nginx/sites-available/default
20-
COPY container/proxy-snippet.conf /etc/nginx/snippets/proxy.conf
21-
22-
RUN mkdir -p /wljs
23-
COPY ./ /wljs/
24-
25-
COPY container/run.sh /run.sh
26-
RUN chmod +x /run.sh
40+
&& rm -rf /var/lib/apt/lists/* \
41+
&& chmod +x /usr/local/bin/run.sh
2742

28-
CMD /run.sh
43+
CMD ["/usr/local/bin/run.sh"]

0 commit comments

Comments
 (0)