diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4e12d86 --- /dev/null +++ b/.dockerignore @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b411d10 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0598ade..efe4e03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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",