From 2a2fcf164ae8a089d50d12cc7af315c5fcf8606b Mon Sep 17 00:00:00 2001 From: RichardHeise <richardfhf5@gmail.com> Date: Fri, 14 Jun 2024 12:02:35 -0300 Subject: [PATCH] Issue #108: OPT docker --- Dockerfile | 15 +++++---------- deploy.sh | 7 +++++++ next.config.mjs | 1 + package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) create mode 100755 deploy.sh diff --git a/Dockerfile b/Dockerfile index c27f42cc..082e1d41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,18 +44,13 @@ ENV NODE_ENV production # Uncomment the following line in case you want to disable telemetry during runtime. ENV NEXT_TELEMETRY_DISABLED 1 -COPY --from=builder /app/ /app/ +COPY --from=builder /app/.next/standalone ./standalone +COPY --from=builder /app/public /app/standalone/public +COPY --from=builder /app/.next/static /app/standalone/.next/static -RUN groupadd --gid 1001 nodejs && useradd --uid 1001 --gid nodejs --shell /bin/bash --create-home nextjs - -RUN chown nextjs:nodejs /app/.next - -USER nextjs -WORKDIR /app - -ENV PORT 3000 EXPOSE 3000 +ENV PORT 3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD ["npm", "start"] +CMD ["node", "./standalone/server.js"] diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 00000000..b026b574 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,7 @@ +#!/bin/env -S sudo /bin/bash + +# Run docker to deploy +docker compose up --build -d + +# Restars nginx +systemctl restart nginx \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 1200c685..87f8cdc7 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', reactStrictMode: false, webpack: (config) => { config.resolve.alias.canvas = false; diff --git a/package-lock.json b/package-lock.json index b3c50b26..d82a043a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend-mecred", - "version": "0.61.0", + "version": "0.62.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frontend-mecred", - "version": "0.61.0", + "version": "0.62.0", "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", diff --git a/package.json b/package.json index 91c71375..e3551f6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frontend-mecred", - "version": "0.61.0", + "version": "0.62.0", "private": true, "scripts": { "dev": "npx next dev", -- GitLab