Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Add dockerfiler & docker compose
Jonathan Adlyfdd3880162e5
diff --git a/.gitignore b/.gitignoreindex 12e1ca9b..39aee32e 100644--- a/.gitignore+++ b/.gitignore@@ -2,3 +2,5 @@# Run logsbackend/run_logs/*++.env\ No newline at end of filediff --git a/README.md b/README.mdindex 538cef63..98ef12f3 100644--- a/README.md+++ b/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`+## 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+## FeedbackIf you have feature requests, bug reports or other feedback, open an issue or ping me on [Twitter](https://twitter.com/_abi_).diff --git a/backend/Dockerfile b/backend/Dockerfilenew file mode 100644index 00000000..f3c61cdb--- /dev/null+++ b/backend/Dockerfile@@ -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/\ No newline at end of filediff --git a/docker-compose.yml b/docker-compose.ymlnew file mode 100644index 00000000..9a76467e--- /dev/null+++ b/docker-compose.yml@@ -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"diff --git a/frontend/.env.example b/frontend/.env.examplenew file mode 100644index 00000000..43a8814c--- /dev/null+++ b/frontend/.env.example@@ -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:7001diff --git a/frontend/Dockerfile b/frontend/Dockerfilenew file mode 100644index 00000000..938e2bff--- /dev/null+++ b/frontend/Dockerfile@@ -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"]\ No newline at end of file