-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (29 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
40 lines (29 loc) · 1.33 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
FROM node:22-alpine
# Create a non-root user before copying files
RUN addgroup -S cosmauser && adduser -S cosmauser -G cosmauser
# Set the working directory and make it accessible to cosmauser
WORKDIR /app
RUN chown cosmauser:cosmauser /app
# Copy dependency files with direct permissions
COPY --chown=cosmauser:cosmauser package.json package-lock.json* ./
# Install dependencies (--ignore-scripts to prevent prepare from triggering the build)
RUN npm ci --ignore-scripts
# Copy source code with direct permissions
COPY --chown=cosmauser:cosmauser . .
# Build the application (webpack front + back)
RUN ./node_modules/.bin/webpack build --config ./webpack-front.config.mjs --mode development
RUN ./node_modules/.bin/webpack build --config ./webpack-back.config.mjs --mode development
RUN npm i . --global
# Create the user data directory with correct permissions
RUN mkdir -p /home/cosmauser/.local/share && \
chown -R cosmauser:cosmauser /home/cosmauser/.local
# Switch to the non-root user
# From this point, cosmauser has:
# - Write access to /app (for config.yml in local mode)
# - Write access to /home/cosmauser/.local/share (for --global and user data dir)
USER cosmauser
# The user data directory will be in /home/cosmauser/.local/share/cosma-cli/
# thanks to env-paths
# Default entrypoint
ENTRYPOINT ["node", "dist/back.cjs"]
CMD ["--help"]