mirror of
https://github.com/R0m1k3/podcastic.git
synced 2026-10-24 07:28:04 +02:00
fix: add proper Dockerfiles for backend and frontend, simplify docker-compose
This commit is contained in:
1 parent
547de27eed
commit
a8787857b5
3 files changed
+26
-83
No files matched your search
+16
-31
@@ -1,49 +1,34 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the app
|
||||
RUN npm run build
|
||||
|
||||
# Production stage - use nginx for serving
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy nginx config
|
||||
RUN echo 'server {\n\
|
||||
listen 3000;\n\
|
||||
server_name _;\n\
|
||||
root /usr/share/nginx/html;\n\
|
||||
index index.html;\n\
|
||||
\n\
|
||||
location / {\n\
|
||||
try_files $uri $uri/ /index.html;\n\
|
||||
}\n\
|
||||
\n\
|
||||
location ~* \\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {\n\
|
||||
expires 1y;\n\
|
||||
add_header Cache-Control "public, immutable";\n\
|
||||
}\n\
|
||||
}' > /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy built app from builder
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
COPY <<'EOF' /etc/nginx/conf.d/default.conf
|
||||
server {
|
||||
listen 3579;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://backend:5000;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
EXPOSE 3579
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in new issue
Block a user