Repository navigation
Expand file tree
/
Copy pathDockerfile.ubuntu
More file actions
66 lines (57 loc) · 2.72 KB
/
Copy pathDockerfile.ubuntu
File metadata and controls
66 lines (57 loc) · 2.72 KB
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
63
64
65
66
# Dockerfile.ubuntu
# Start from the official Ubuntu-based node.js Docker image
FROM node:24
ARG BUILD_DATE
LABEL build-date=$BUILD_DATE
LABEL maintainer="ZHAO Xudong <zxdong@gmail.com>"
LABEL description="This is Docker image for electerm-web"
LABEL url="https://github.com/electerm/electerm-web-docker"
LABEL vendor="electerm"
LABEL version="5.20.0"
# Additional standard Docker labels
LABEL org.opencontainers.image.title="electerm-web"
LABEL org.opencontainers.image.description="Docker image for electerm-web - SSH/SFTP/Telnet terminal client"
LABEL org.opencontainers.image.source="https://github.com/electerm/electerm-web-docker"
LABEL org.opencontainers.image.url="https://github.com/electerm/electerm-web-docker"
LABEL org.opencontainers.image.documentation="https://github.com/electerm/electerm-web-docker"
LABEL org.opencontainers.image.version="5.20.0"
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.authors="ZHAO Xudong <zxdong@gmail.com>"
LABEL org.opencontainers.image.vendor="electerm"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.ref.name="electerm-web"
LABEL org.opencontainers.image.base.name="node:24"
# Install the build tools necessary for node-gyp and additional tools
RUN apt-get update && apt-get install -y git python-is-python3 make build-essential g++ curl \
# Create the electerm user and group
&& groupadd -r electerm && useradd -r -g electerm -d /home/electerm -s /bin/bash electerm \
&& mkdir -p /home/electerm \
&& chown -R electerm:electerm /home/electerm && chmod 755 /home/electerm
WORKDIR /app
RUN chown -R electerm:electerm /app
# Switch to electerm user for building the application
USER electerm:electerm
# Upstream ref the image is built from: a tag for a reproducible image, `main`
# to track the latest commit. Bump it together with the version labels above.
# BASE_PATH support landed in 5.10.x, so anything older ignores the env var.
ARG ELECTERM_WEB_REF=main
# Clone and build the application
RUN git clone --depth 1 --branch ${ELECTERM_WEB_REF} https://github.com/electerm/electerm-web.git
WORKDIR /app/electerm-web
RUN npm config set legacy-peer-deps true \
&& npm i \
&& npm run build \
&& cp .sample.env .env \
&& npm prune --production \
&& npm cache clean --force
# Switch back to root for cleanup
USER root
RUN apt-get remove -y git python-is-python3 make build-essential g++ && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app/electerm-web
# Set the environment variables
ENV NODE_ENV=production
# HOME points to data directory so logs/config are written to mounted volume
ENV HOME=/home/electerm/data
# No USER directive - allow --user flag to set runtime user
# This enables: docker run --user $(id -u):$(id -g) ...
CMD ["node", "./src/app/app.js"]