-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
executable file
·54 lines (44 loc) · 1.33 KB
/
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
FROM node:alpine
# Set default values for build arguments
ARG USER_UID=1000
ARG USER_GID=1000
ARG USERNAME=node
ARG USER_HOME=/home/node
# Install necessary packages in a single layer
RUN apk update && apk add --no-cache \
git \
zsh \
shadow \
perl \
gcompat \
bash \
curl \
build-base \
netcat-openbsd \
libc++ \
&& rm -rf /var/cache/apk/*
# Set up user and permissions in a single layer
RUN if getent passwd node; then deluser node; fi && \
if getent group node; then delgroup node; fi && \
addgroup -g ${USER_GID} -S ${USERNAME} && \
adduser -u ${USER_UID} -S -s /bin/bash -G ${USERNAME} ${USERNAME} && \
mkdir -p ${USER_HOME}/tmpfs ${USER_HOME}/workspace ${USER_HOME}/.yarn && \
chown -R ${USERNAME} ${USER_HOME} && \
corepack enable
# Set environment variables
ENV HOME=${USER_HOME} \
PATH=${USER_HOME}/.local/bin:${PATH} \
SHELL=/bin/bash
# Create volume for temporary storage
# Copy entrypoint script
COPY --chown=root:root docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Switch to non-root user
USER ${USERNAME}
VOLUME ["${USER_HOME}/tmpfs"]
VOLUME ["${USER_HOME}/workspace"]
VOLUME ["${USER_HOME}/.yarn"]
# Set working directory
WORKDIR ${USER_HOME}/workspace
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["bash"]