first commit
This commit is contained in:
61
bot/Dockerfile
Normal file
61
bot/Dockerfile
Normal file
@@ -0,0 +1,61 @@
|
||||
# Multi-stage build dla optymalizacji
|
||||
FROM node:18-alpine AS base
|
||||
|
||||
# Ustaw workdir
|
||||
WORKDIR /app
|
||||
|
||||
# Kopiuj package.json dla głównego projektu
|
||||
COPY package*.json ./
|
||||
|
||||
# Zainstaluj zależności głównego projektu
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Stage dla frontendu
|
||||
FROM node:18-alpine AS frontend-build
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Kopiuj package.json frontendu
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Kopiuj kod frontendu
|
||||
COPY frontend/ ./
|
||||
|
||||
# Zbuduj frontend
|
||||
RUN npm run build
|
||||
|
||||
# Stage dla backend
|
||||
FROM node:18-alpine AS backend
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Kopiuj zależności z base stage
|
||||
COPY --from=base /app/node_modules ./node_modules
|
||||
COPY package*.json ./
|
||||
|
||||
# Kopiuj kod backend
|
||||
COPY backend/ ./backend/
|
||||
COPY database/ ./database/
|
||||
COPY shared/ ./shared/
|
||||
|
||||
# Kopiuj zbudowany frontend
|
||||
COPY --from=frontend-build /app/frontend/build ./frontend/build
|
||||
|
||||
# Stwórz użytkownika non-root
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S nodejs -u 1001
|
||||
|
||||
# Zmień ownership plików
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
USER nodejs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:3000/api/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
|
||||
|
||||
# Uruchom aplikację
|
||||
CMD ["node", "backend/index.js"]
|
||||
Reference in New Issue
Block a user