From 5da68bbdd45e29df76e4d5833c8543e49235ca77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=89VEIL?= Date: Sun, 19 Mar 2023 13:49:41 +0100 Subject: [PATCH] :whale: add Dockerfile (#17) Co-authored-by: dev --- .dockerignore | 4 ++++ Dockerfile | 27 +++++++++++++++++++++++++++ README.md | 8 ++++++++ docker-compose.yml | 9 +++++++++ 4 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a488db6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.env +.env.local +node_modules + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8998a71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# ---- Base Node ---- +FROM node:19-alpine AS base +WORKDIR /app +COPY package*.json ./ + +# ---- Dependencies ---- +FROM base AS dependencies +RUN npm ci + +# ---- Build ---- +FROM dependencies AS build +COPY . . +RUN npm run build + +# ---- Production ---- +FROM node:19-alpine AS production +WORKDIR /app +COPY --from=dependencies /app/node_modules ./node_modules +COPY --from=build /app/.next ./.next +COPY --from=build /app/public ./public +COPY --from=build /app/package*.json ./ + +# Expose the port the app will run on +EXPOSE 3000 + +# Start the application +CMD ["npm", "start"] diff --git a/README.md b/README.md index 9da554d..6bce1de 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,14 @@ Host your own live version of Chatbot UI with Vercel. Fork Chatbot UI on Replit [here](https://replit.com/@MckayWrigley/chatbot-ui-pro?v=1). + +**Docker** + +```shell +docker build -t chatgpt-ui . +docker run -e OPENAI_API_KEY=xxxxxxxx -p 3000:3000 chatgpt-ui +``` + ## Running Locally **1. Clone Repo** diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..85fa1d7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.6' + +services: + chatgpt: + build: . + ports: + - 3000:3000 + environment: + - 'OPENAI_API_KEY='