From dab127aed7e5a42f745e9dd3b866b6aaa8c98da5 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Wed, 18 Sep 2024 18:32:16 -0400 Subject: [PATCH] dockerized build system --- Dockerfile | 21 +++++++++++++++++++++ docker-compose.yml | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72366a4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Use the Node.js 18 Alpine Linux image as the base image +FROM node:22-alpine + +# Set the working directory inside the container to /app +WORKDIR /app + +# Copy package.json and package-lock.json files into the working directory +COPY package*.json ./ + +# Install the dependencies specified in package.json +RUN npm install -g pnpm +RUN pnpm install + +# Copy all the files from the local directory to the working directory in the container +COPY . . + +# Push database schema to database +RUN pnpm drizzle-kit push + +# Run the application in development mode +CMD ["pnpm", "run", "dev"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5d7db53 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +# Use Docker Compose file format version 3.9 +# version: '3.9' + +services: + app: + build: + context: . + dockerfile: Dockerfile + ports: + - '3000:3000' # Node.js + - '4983:4983' # Drizzle Studio + volumes: + - .:/app + - /app/node_modules + environment: + NODE_ENV: development + command: ["pnpm", "run", "dev"] + + db: + image: postgres + restart: always + # ports: + # - 5432:5432 # DEBUG + volumes: + - postgres:/var/lib/postgresql/data + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + + adminer: + image: adminer + restart: always + ports: + - 8080:8080 + +volumes: + postgres: