From 6109c2ce71f0f49f49952e3c90c09f818f9a0394 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 3 Nov 2024 14:13:41 +0100 Subject: [PATCH] Prepare setup for development with Docker --- .dockerignore | 13 +++++++++++++ Dockerfile.dev | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile.dev diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b6b7a04 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +.next +*.swp +/scripts diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..7ed40bd --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,28 @@ +# Based on https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile + +FROM node:23-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +COPY . /app/ + +ENV NODE_ENV development +ENV NEXT_TELEMETRY_DISABLED 1 + +EXPOSE 3000 +ENV PORT=3000 + +CMD HOSTNAME="0.0.0.0" pnpm run dev \ No newline at end of file