add docker

This commit is contained in:
Maxim
2025-12-12 03:33:28 +03:00
parent cc4809019d
commit f3203bb559
3 changed files with 101 additions and 11 deletions

49
.dockerignore Normal file
View File

@@ -0,0 +1,49 @@
# Dependencies
node_modules
npm-debug.log
yarn-error.log
.pnpm-debug.log*
# Nuxt build output
.output
.nuxt
dist
.nitro
.cache
# Environment files
.env
.env.*
# IDE
.idea
.vscode
*.sublime-project
*.sublime-workspace
.DS_Store
# Logs
logs
*.log
# Testing
coverage
.nyc_output
# Git
.git
.gitignore
# Documentation
*.md
LICENSE
# Docker
Dockerfile
.dockerignore
docker-compose*.yml
# CI/CD
.github
.gitlab-ci.yml
.travis.yml

41
Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
# Stage 1: Dependencies
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
RUN npm ci
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application
RUN npm run build
# Stage 3: Runner
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Add non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nuxtjs -u 1001
# Copy built application
COPY --from=builder --chown=nuxtjs:nodejs /app/.output ./.output
# Switch to non-root user
USER nuxtjs
# Expose the port
EXPOSE 3000
# Start the application
CMD ["node", ".output/server/index.mjs"]

22
package-lock.json generated
View File

@@ -6515,17 +6515,6 @@
"integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==",
"license": "MIT"
},
"node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
"license": "MIT",
"optional": true,
"peer": true,
"engines": {
"node": ">= 10"
}
},
"node_modules/commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
@@ -13862,6 +13851,17 @@
"url": "https://opencollective.com/svgo"
}
},
"node_modules/svgo/node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">= 10"
}
},
"node_modules/svgo/node_modules/css-tree": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz",