-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (61 loc) · 2.45 KB
/
Dockerfile
File metadata and controls
77 lines (61 loc) · 2.45 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
67
68
69
70
71
72
73
74
75
76
77
# Use the latest udx-worker as the base image
FROM usabilitydynamics/udx-worker:0.40.0
# Add metadata labels
LABEL version="0.31.0"
# Set build arguments for Node.js version and application port
ARG NODE_VERSION=24.13.1
ARG APP_PORT=8080
# Add Node.js to PATH
ENV PATH="/usr/local/bin:/usr/local/node/bin:${PATH}"
# Set application-specific environment variables
ENV APP_HOME="/usr/src/app" \
APP_PORT="${APP_PORT}"
# Use root user for Node.js installation
USER root
# Set shell with pipefail option for safer pipe operations
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Set working directory for Node.js installation
WORKDIR /tmp
# Install required packages for Node.js extraction
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends xz-utils=5.8.1-1build2 && \
rm -rf /var/lib/apt/lists/*
# Install Node.js
RUN set -ex && \
# Detect architecture
ARCH=$(dpkg --print-architecture 2>/dev/null || echo "x64") && \
if [ "$ARCH" = "amd64" ]; then ARCH="x64"; fi && \
if [ "$ARCH" = "arm64" ]; then ARCH="arm64"; fi && \
# Download Node.js binary and checksum
curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" && \
curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" && \
# Verify checksum
grep " node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$" SHASUMS256.txt | sha256sum -c - && \
# Extract and install
mkdir -p /usr/local/node && \
tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" --strip-components=1 -C /usr/local/node && \
ln -sf /usr/local/node/bin/node /usr/local/bin/node && \
# Verify installation and resolution path
node --version && \
command -v npm && head -n 1 "$(command -v npm)" && npm --version && \
rm -rf /tmp/*
# Remove xz-utils as it's no longer needed
RUN apt-get purge -y --auto-remove xz-utils && \
rm -rf /var/lib/apt/lists/*
# Copy application files
# Create application directory
RUN mkdir -p "${APP_HOME}" && \
chown -R "${USER}:${USER}" "${APP_HOME}" && \
chmod -R 755 "${APP_HOME}"
# Copy license and examples
COPY --chown=${USER}:${USER} LICENSE "${APP_HOME}/LICENSE"
# Expose the application port
EXPOSE ${APP_PORT}
# Switch to the non-root user and set working directory
USER "${USER}"
WORKDIR "${APP_HOME}"
# Use the parent image's entrypoint
ENTRYPOINT ["/usr/local/worker/bin/entrypoint.sh"]
# Use the default command from parent image
CMD ["tail", "-f", "/dev/null"]