Skip to content

Commit

Permalink
Merge pull request #27 from quaternionmedia/main
Browse files Browse the repository at this point in the history
Catch #23 up to main
  • Loading branch information
CameronRWest authored Oct 3, 2023
2 parents 6e49d63 + 1efe259 commit 800dbdd
Show file tree
Hide file tree
Showing 18 changed files with 483 additions and 217 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ output/
.vscode/
..vscode/
.git/
token.txt
secrets.txt

# package files
config.json
Expand Down
50 changes: 50 additions & 0 deletions docker-compose.debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,53 @@
# ports:
# - 2000:2000
# - 5678:5678

version: '3'

services:
web:
build:
context: .
dockerfile: ./src/codecarto/containers/web/Dockerfile
ports:
- '2000:2000'
networks:
- external_network
- internal_network
# volumnes are for quicker docker builds during development
volumes:
- ./src/codecarto/containers/web/api:/app/api
- ./src/codecarto/containers/web/src:/app/src

processor:
build:
context: .
dockerfile: ./src/codecarto/containers/processor/Dockerfile
secrets:
- github_token
networks:
- internal_network
# volumnes are for quicker docker builds during development
volumes:
- ./src/codecarto/containers/processor/api:/app/api
- ./src/codecarto/containers/processor/src:/app/src

database:
image: mongo:latest
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: examplepassword
networks:
- internal_network

networks:
external_network:
driver: bridge
internal_network:
driver: bridge

secrets:
github_token:
file: ./token.txt
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
build:
context: .
dockerfile: ./src/codecarto/containers/processor/Dockerfile
secrets:
- github_token
networks:
- internal_network

Expand All @@ -35,3 +37,7 @@ networks:
driver: bridge
internal_network:
driver: bridge

secrets:
github_token:
file: ./token.txt
11 changes: 8 additions & 3 deletions src/codecarto/containers/processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY ./src/codecarto/containers/processor/requirements.txt .
RUN python -m pip install -r requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install -r requirements.txt

# Directory
WORKDIR /app
Expand All @@ -19,10 +20,14 @@ COPY ./src/codecarto/containers/processor/src /app/src
ENV PYTHONPATH=/app

# # Creates a non-root user with an explicit UID and adds permission to access the /app folder
# # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
# RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
# USER appuser
# # Good idea to also remove the shell access and ensure there is no home directory for the user
# RUN addgroup --gid 1001 --system app && \
# adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group app
# USER app


# # During debugging, this entry point will be overridden.
# For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:2020", "-k", "uvicorn.workers.UvicornWorker", "api.main:app"]
CMD ["gunicorn", "--bind", "0.0.0.0:2020", "-k", "uvicorn.workers.UvicornWorker", "api.main:app"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fastapi.responses import JSONResponse

from src.plotter.palette import Theme
from api.util import generate_return, proc_exception
from api.util import generate_return, proc_exception, proc_error

PaletteRoute: APIRouter = APIRouter()
default_palette_path: str = "src/plotter/default_palette.json"
Expand Down Expand Up @@ -33,7 +33,7 @@ async def get_palette(user_id: int = -1) -> dict:
with open(file_path, "r") as f:
pal_data = load(f)

return generate_return("success", "Proc - Success", pal_data)
return generate_return(200, "Proc - Success", pal_data)
except Exception as e:
proc_exception(
"get_palette",
Expand Down Expand Up @@ -73,10 +73,11 @@ async def set_palette(user_id: int = -1, new_pal_data: dict = {}) -> dict:

return pal_data
else:
proc_exception(
return proc_error(
"set_palette",
"No new palette data provided",
{"user_id": user_id, "new_pal_data": new_pal_data},
500,
)
except Exception as e:
proc_exception(
Expand Down
Loading

0 comments on commit 800dbdd

Please sign in to comment.