-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (52 loc) · 1.82 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
55
56
57
58
59
60
61
62
ARG NODE_VERSION
FROM node:${NODE_VERSION}-alpine
ARG USER_ID
ARG GROUP_ID
ARG USERNAME
ARG GROUP_NAME
ARG NPM_VERSION
RUN apk add --no-cache \
wget \
curl \
nano \
npm \
bash \
bash-completion \
sudo \
chromium \
shadow && \
npm install -g npm@${NPM_VERSION} && \
npm install -g @angular/cli && \
npm install -g @ionic/cli
RUN set -xe; \
\
# Create group if on only if group identified by GID not occupied.
existing_group=$(getent group "${GROUP_ID}" | cut -d: -f1); \
if [[ -n "${existing_group}" ]]; then \
echo "The group with GID ${GROUP_ID} already exists. Skipping group creation."; \
GROUP_NAME=$existing_group; \
else \
/usr/sbin/groupadd --gid "${GROUP_ID}" "${GROUP_NAME}" --force; \
fi; \
# Create user if on only if user identified by UID not occupied.
existing_user=$(getent passwd "${USER_ID}" | cut -d: -f1); \
if [[ -n "${existing_user}" ]]; then \
echo "The user with UID ${USER_ID} already exists. Skipping user creation."; \
USERNAME=$existing_user; \
else \
/usr/sbin/useradd --create-home --shell /bin/bash --gid "${GROUP_ID}" --uid ${USER_ID} "${USERNAME}"; \
fi; \
\
echo "${USERNAME} ALL=(root) NOPASSWD:ALL" >/etc/sudoers.d/"${USERNAME}"; \
echo chmod 0440 /etc/sudoers.d/"${USERNAME}";
#COPY ./.bashrc /home/${USERNAME}/.bashrc
#COPY ./.profile /home/${USERNAME}/.profile
#COPY ./.bash_aliases /home/${USERNAME}/.bash_aliases
RUN echo "uid=${USER_ID}(${USERNAME}) gid=${GROUP_NAME}(${GROUP_ID})";
ENV CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/lib/chromium/
#RUN chown $USERNAME:$GROUP_NAME /home/${USERNAME}/.bashrc \
# /home/${USERNAME}/.profile \
# /home/${USERNAME}/.bash_aliases
#RUN chown -R $USERNAME: /usr/local/{lib/node_modules,bin,share}
USER $USERNAME