Merge main into sweep/add-sweep-config

This commit is contained in:
sweep-ai[bot] 2023-11-20 02:54:44 +00:00 committed by GitHub
commit db945117f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 3 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
# Run logs # Run logs
backend/run_logs/* backend/run_logs/*
.env

View File

@ -28,7 +28,7 @@ cd backend
echo "OPENAI_API_KEY=sk-your-key" > .env echo "OPENAI_API_KEY=sk-your-key" > .env
poetry install poetry install
poetry shell poetry shell
poetry run uvicorn main:app --reload --port 7000 poetry run uvicorn main:app --reload --port 7001
``` ```
Run the frontend: Run the frontend:
@ -43,6 +43,17 @@ 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
If you have Docker installed on your system, in the root directory, run:
```bash
echo "OPENAI_API_KEY=sk-your-key" > .env
docker-compose up -d --build
```
The app will be up and running at http://localhost:5173. Note that you can't develop the application with this setup as the file changes won't trigger a rebuild.
## 🙋‍♂️ FAQs ## 🙋‍♂️ FAQs
- **I'm running into an error when setting up the backend. How can I fix it?** [Try this](https://github.com/abi/screenshot-to-code/issues/3#issuecomment-1814777959). If that still doesn't work, open an issue. - **I'm running into an error when setting up the backend. How can I fix it?** [Try this](https://github.com/abi/screenshot-to-code/issues/3#issuecomment-1814777959). If that still doesn't work, open an issue.

21
backend/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM python:3.12-slim-bullseye
ENV POETRY_VERSION 1.4.1
# 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
# Copy the current directory contents into the container at /app
COPY ./ /app/

27
docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: '3.9'
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
env_file:
- .env
# or
# environment:
#- BACKEND_PORT=7001 # 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:-7001}:${BACKEND_PORT:-7001}"
command: poetry run uvicorn main:app --host 0.0.0.0 --port ${BACKEND_PORT:-7001}
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "5173:5173"

1
frontend/.env.example Normal file
View File

@ -0,0 +1 @@
VITE_WS_BACKEND_URL=ws://127.0.0.1:7001

19
frontend/Dockerfile Normal file
View 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"]

View File

@ -1,7 +1,7 @@
import toast from "react-hot-toast"; import toast from "react-hot-toast";
const WS_BACKEND_URL = const WS_BACKEND_URL =
import.meta.env.VITE_WS_BACKEND_URL || "ws://127.0.0.1:7000"; import.meta.env.VITE_WS_BACKEND_URL || "ws://127.0.0.1:7001";
const ERROR_MESSAGE = const ERROR_MESSAGE =
"Error generating code. Check the Developer Console for details. Feel free to open a Github issue"; "Error generating code. Check the Developer Console for details. Feel free to open a Github issue";