diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..48959d83 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.next +.git +.vscode +.env* +!.env.production +docker-compose.yml diff --git a/.gitignore b/.gitignore index 4a4f270a..72b85879 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ yarn-error.log* .env .env.local .env.*.local +.env.production # vercel .vercel diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5706055c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Use Node.js 22 as the base image +FROM node:22-alpine AS builder + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy the rest of the application files +COPY . . + +# Build the Next.js application +RUN npm run build + +# Production stage +FROM node:22-alpine AS runner + +# Set the working directory +WORKDIR /app + +# Copy only necessary files from the builder stage +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +# Set environment variables +ENV NODE_ENV=production +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/README.md b/README.md index 2fc5f5d8..66321559 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,11 @@ The theme is based on [ChakraUI](https://chakra-ui.com/) and can be [customized] #### Application Your application includes default navigation, metadata, and wallets that can be updated directly from the `pages/_app.tsx` file. + +## Build and publish Docker image + +Make sure to have the envs in the file `.env.production`. + +```bash +docker build -t IMAGE_TAG --platform linux/amd64 --push . +``` diff --git a/next.config.js b/next.config.js index ccdbbc58..c400ac5d 100644 --- a/next.config.js +++ b/next.config.js @@ -9,6 +9,7 @@ const removeImports = require('next-remove-imports')() * @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', images: { minimumCacheTTL: 3600 * 24 * 365, // 1 year remotePatterns: [