From 403832f90a22d1dd8e2952ddbcd7a5f30a83e541 Mon Sep 17 00:00:00 2001 From: Alessio Menichinelli Date: Sat, 1 Jun 2024 11:22:01 +0200 Subject: [PATCH] feat: add docker files --- Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ Dockerfile_copy | 40 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 Dockerfile create mode 100644 Dockerfile_copy diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ca1053 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# Use Node.js 20 +FROM node:20 + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY frontend/package.json frontend/ +COPY api/package.json api/ +COPY shared/package.json shared/ + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +# Install pnpm 8 +RUN npm install -g pnpm@8 + +# Install dependencies +RUN pnpm install + +# Copy all files to the container +COPY . . + +# Check formatting +RUN pnpm run format-check + +# Build the app +RUN pnpm run build + +# Expose the port +EXPOSE 5173 + +ENV PORT 5173 +# set hostname to localhost +ENV HOSTNAME "0.0.0.0" + +# Start the app +CMD ["pnpm", "dev:web"] + diff --git a/Dockerfile_copy b/Dockerfile_copy new file mode 100644 index 0000000..9e74221 --- /dev/null +++ b/Dockerfile_copy @@ -0,0 +1,40 @@ +# Use Node.js 20 +FROM node:20 + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY frontend/package.json frontend/ +COPY api/package.json api/ +COPY shared/package.json shared/ + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +# Install pnpm 8 +RUN npm install -g pnpm@8 + +# Install dependencies +RUN pnpm install + +# Copy all files to the container +COPY . . + +# Check formatting +RUN pnpm run format-check + +# Build the app +RUN pnpm run build + +# Expose the port +EXPOSE 3000 + +ENV PORT 3000 +# set hostname to localhost +ENV HOSTNAME "0.0.0.0" + +# Start the app +CMD ["pnpm", "dev:api"] + diff --git a/docker-compose.yml b/docker-compose.yml index f0377c6..f14af00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,26 @@ services: - POSTGRES_DB=hkrecruitment ports: - '5432:5432' + + + web: + build: + context: . + dockerfile: Dockerfile + env_file: + - .env + ports: + - '5173:5173' + depends_on: + - db + + api: + build: + context: . + dockerfile: Dockerfile_copy + env_file: + - .env + ports: + - '3000:3000' + depends_on: + - db \ No newline at end of file