Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

feat: add local docker compose

Dillion Verma3db87453b52d
diff --git a/dev.Dockerfile b/dev.Dockerfile
new file mode 100644
index 00000000..16eabcbf
--- /dev/null
+++ b/dev.Dockerfile
@@ -0,0 +1,32 @@
+FROM node:20-alpine
+
+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; \
+ # Allow install without lockfile, so example works even without Node.js installed locally
+ else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
+ fi
+
+COPY src ./src
+COPY public ./public
+COPY next.config.js .
+COPY tsconfig.json .
+
+# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
+# Uncomment the following line to disable telemetry at run time
+# ENV NEXT_TELEMETRY_DISABLED 1
+
+# Note: Don't expose ports here, Compose will handle that for us
+
+# Start Next.js in development mode based on the preferred package manager
+CMD \
+ if [ -f yarn.lock ]; then yarn dev; \
+ elif [ -f package-lock.json ]; then npm run dev; \
+ elif [ -f pnpm-lock.yaml ]; then pnpm dev; \
+ else npm run dev; \
+ fi
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index 5fa38ad7..a69b672f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,20 +5,44 @@ version: "3.7"
# docker-compose up -d
#
+# https://github.com/vercel/next.js/blob/canary/examples/with-docker-compose/docker-compose.dev.yml
+
services:
- default_database:
+ web:
+ build:
+ context: .
+ dockerfile: dev.Dockerfile
+ volumes:
+ - ./src:/app/src
+ - ./public:/app/public
+ ports:
+ - "3000:3000"
+ environment:
+ - DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
+ env_file:
+ - .env.local
+ restart: always
+
+
+ database:
restart: unless-stopped
image: postgres:latest
volumes:
- - default_database_data:/var/lib/postgresql/data
+ - database_data:/var/lib/postgresql/data
environment:
- - POSTGRES_DB=${DEFAULT_DATABASE_DB}
- - POSTGRES_USER=${DEFAULT_DATABASE_USER}
- - POSTGRES_PASSWORD=${DEFAULT_DATABASE_PASSWORD}
+ - POSTGRES_DB=postgres
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=postgres
env_file:
- - .env
+ - .env.local
ports:
- - "${DEFAULT_DATABASE_PORT}:5432"
+ - "5432:5432"
+ networks:
+ - my_network
volumes:
- default_database_data:
+ database_data:
+
+networks:
+ my_network:
+ external: true
\ No newline at end of file