-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (50 loc) · 1.86 KB
/
Dockerfile
File metadata and controls
65 lines (50 loc) · 1.86 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
FROM node:18-alpine AS builder
# Install pnpm and required build dependencies
RUN apk add --no-cache python3 make g++
RUN corepack enable && corepack prepare pnpm@8.15.4 --activate
WORKDIR /app
# Copy package files first to leverage Docker cache
COPY package.json pnpm-lock.yaml ./
# Install dependencies with force to handle lockfile compatibility
ENV ROLLUP_SKIP_NODE_RESOLUTION=true
RUN pnpm install
# Copy source files
COPY src ./src
COPY public ./public
COPY index.html vite.config.mjs tsconfig.json tailwind.config.js .eslintrc* ./
COPY .git ./.git
# Create git commit file from current branch HEAD
RUN if [ -d ".git" ]; then \
echo "export const gitCommit = '$(cat .git/HEAD | cut -d '/' -f 3- | xargs -I {} cat .git/refs/heads/{} | cut -c 1-8)';" > src/_gitCommit.ts; \
else \
echo "export const gitCommit = 'dev';" > src/_gitCommit.ts; \
fi
# Build the app
ENV NODE_ENV=production
ENV DISABLE_ESLINT_PLUGIN=true
RUN pnpm run build
# Production stage
FROM nginx:alpine
# Create necessary directories and set permissions
RUN mkdir -p /tmp/nginx /tmp/client_temp /tmp/proxy_temp_path /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_temp && \
mkdir -p /var/cache/nginx /var/log/nginx && \
chown -R nginx:nginx /tmp && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
# Remove default nginx config
rm -rf /etc/nginx/conf.d/* && \
rm -f /etc/nginx/nginx.conf
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy built files from builder
COPY --from=builder /app/build /usr/share/nginx/html
# Set correct permissions
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chmod -R 755 /usr/share/nginx/html && \
chown -R nginx:nginx /etc/nginx && \
chmod -R 755 /etc/nginx
# Expose port 8370
EXPOSE 8370
# Switch to non-root user
USER nginx
CMD ["nginx", "-g", "daemon off;"]