-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (44 loc) · 1.37 KB
/
Dockerfile
File metadata and controls
59 lines (44 loc) · 1.37 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
# Build stage
FROM node:23-alpine as build
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
COPY docker.env .env
# Build the app
RUN npm run build
# Serve stage
FROM nginx:alpine
# Create a non-root user to run nginx
RUN adduser -D -H -u 1001 -s /sbin/nologin webuser
# Create app directory
RUN mkdir -p /app/www
# Copy built assets from build stage
COPY --from=build /app/dist /app/www
# Copy nginx config template
COPY nginx.conf /etc/nginx/templates/default.conf.template
# Set correct ownership and permissions
RUN chown -R webuser:webuser /app/www && \
chmod -R 755 /app/www && \
# Nginx needs to read and write to these directories
chown -R webuser:webuser /var/cache/nginx && \
chown -R webuser:webuser /var/log/nginx && \
chown -R webuser:webuser /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R webuser:webuser /var/run/nginx.pid && \
chmod -R 777 /etc/nginx/conf.d
# Expose port (will be overridden by Render)
EXPOSE 80
# Tell nginx's template processing which variables to replace
ENV NGINX_ENVSUBST_TEMPLATE_DIR=/etc/nginx/templates
ENV NGINX_ENVSUBST_TEMPLATE_SUFFIX=.template
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/conf.d
ENV PORT=80
# Switch to non-root user
USER webuser
# Start nginx
CMD ["nginx", "-g", "daemon off;"]