-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
54 lines (39 loc) · 954 Bytes
/
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
51
52
53
54
ARG USER_ID=1000
ARG USER_NAME=latex
ARG USER_HOME=/home/latex
ARG USER_GECOS=LaTeX
ARG BASE_IMAGE=ghcr.io/felix-kaestner/latex:1.0
FROM ${BASE_IMAGE} as latex
ARG USER_NAME
ARG USER_HOME
ARG USER_ID
ARG USER_GECOS
USER root
# delete default latex user
RUN deluser \
--remove-home \
"latex"
# create new user from build arguments
RUN adduser \
--home "$USER_HOME" \
--uid $USER_ID \
--gecos "$USER_GECOS" \
--disabled-password \
"$USER_NAME"
# create user home directory and set permissions
RUN mkdir -p $USER_HOME \
&& chown "$USER_NAME:$USER_NAME" $USER_HOME
# switch into home directory as working directory
WORKDIR $USER_HOME
# switch to new user
USER $USER_NAME
FROM latex as build
ARG USER_NAME
ARG USER_HOME
COPY --chown=$USER_NAME:$USER_NAME . $USER_HOME
RUN latexmk thesis
FROM scratch
ARG USER_HOME
# Copy the pdf into the image.
COPY --from=build $USER_HOME/thesis.pdf /
COPY --from=build $USER_HOME/thesis.log /