Add dockerfiler & docker compose
This commit is contained in:
parent
a776ce53cb
commit
fdd3880162
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
# Run logs
|
# Run logs
|
||||||
backend/run_logs/*
|
backend/run_logs/*
|
||||||
|
|
||||||
|
.env
|
||||||
16
README.md
16
README.md
@ -38,6 +38,22 @@ Open http://localhost:5173 to use the app.
|
|||||||
|
|
||||||
If you prefer to run the backend on a different port, update VITE_WS_BACKEND_URL in `frontend/.env.local`
|
If you prefer to run the backend on a different port, update VITE_WS_BACKEND_URL in `frontend/.env.local`
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "OPENAI_API_KEY=sk-your-key" > .env
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to change the backend port to something other than 7000 (default) - for example, 7001. Then:
|
||||||
|
|
||||||
|
1. `echo "BACKEND_PORT=7001"`
|
||||||
|
2. `echo VITE_WS_BACKEND_URL=ws://127.0.0.1:7001 > frontend/.env.local`
|
||||||
|
|
||||||
|
Port 7000 sometimes is used by Airplay if you are on a mac. This will solve the docker error "Ports are not available... address already in use"
|
||||||
|
|
||||||
|
Application will be up and running at http://localhost:5173
|
||||||
|
|
||||||
## Feedback
|
## Feedback
|
||||||
|
|
||||||
If you have feature requests, bug reports or other feedback, open an issue or ping me on [Twitter](https://twitter.com/_abi_).
|
If you have feature requests, bug reports or other feedback, open an issue or ping me on [Twitter](https://twitter.com/_abi_).
|
||||||
|
|||||||
35
backend/Dockerfile
Normal file
35
backend/Dockerfile
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
FROM python:3.12-slim-bullseye
|
||||||
|
|
||||||
|
#ARG YOUR_ENV # Set your environment variable (prod vs. dev)
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
ENV PYTHONFAULTHANDLER 1
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
ENV PYTHONHASHSEED random
|
||||||
|
ENV PIP_NO_CACHE_DIR off
|
||||||
|
ENV PIP_DISABLE_PIP_VERSION_CHECK on
|
||||||
|
ENV PIP_DEFAULT_TIMEOUT 100
|
||||||
|
ENV POETRY_VERSION 1.4.1
|
||||||
|
#ENV ENVIRONMENT $YOUR_ENV
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN pip install "poetry==$POETRY_VERSION"
|
||||||
|
|
||||||
|
# Set work directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy only requirements to cache them in docker layer
|
||||||
|
COPY poetry.lock pyproject.toml /app/
|
||||||
|
|
||||||
|
# Disable the creation of virtual environments
|
||||||
|
RUN poetry config virtualenvs.create false
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN poetry install
|
||||||
|
|
||||||
|
# if you have dev dependencies and runnning in production
|
||||||
|
#poetry install $(test "$YOUR_ENV" == production && echo "--no-dev") --no-interaction --no-ansi
|
||||||
|
|
||||||
|
# Copy the current directory contents into the container at /app
|
||||||
|
COPY ./ /app/
|
||||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
|
||||||
|
# or
|
||||||
|
# environment:
|
||||||
|
#- BACKEND_PORT=7000 # if you change the port, make sure to also change the VITE_WS_BACKEND_URL at frontend/.env.local
|
||||||
|
# - OPENAI_API_KEY=your_openai_api_key
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "${BACKEND_PORT:-7000}:${BACKEND_PORT:-7000}"
|
||||||
|
|
||||||
|
command: poetry run uvicorn main:app --host 0.0.0.0 --port ${BACKEND_PORT:-7000}
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
2
frontend/.env.example
Normal file
2
frontend/.env.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# example for change the backend port to 7001 to deal with issue: https://developer.apple.com/forums/thread/682332
|
||||||
|
VITE_WS_BACKEND_URL=ws://127.0.0.1:7001
|
||||||
19
frontend/Dockerfile
Normal file
19
frontend/Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM node:20.9-bullseye-slim
|
||||||
|
|
||||||
|
# Set the working directory in the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package.json and yarn.lock
|
||||||
|
COPY package.json yarn.lock /app/
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
# Copy the current directory contents into the container at /app
|
||||||
|
COPY ./ /app/
|
||||||
|
|
||||||
|
# Expose port 5173 to access the server
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
# Command to run the application
|
||||||
|
CMD ["yarn", "dev", "--host", "0.0.0.0"]
|
||||||
Loading…
Reference in New Issue
Block a user