Fix(Docker): Seperate DEV and PROD
- Restructured the project
This commit is contained in:
parent
975efc5ee9
commit
782fa386d5
12
README.md
12
README.md
@ -1 +1,11 @@
|
||||
# neo-neo-todo
|
||||
# Neo Neo Todo API
|
||||
|
||||
## Backend
|
||||
|
||||
- Run the live `uvicorn` webserver with `uvicorn neo_neo_todo.main:app --reload` at the backend root.
|
||||
|
||||
### Backend dependencies
|
||||
|
||||
## Frontend
|
||||
|
||||
## Frontend dependencies
|
||||
|
12
backend/.dockerignore
Normal file
12
backend/.dockerignore
Normal file
@ -0,0 +1,12 @@
|
||||
# Python files
|
||||
__pycache__/
|
||||
.venv/
|
||||
|
||||
# ide files
|
||||
.vscode/
|
||||
|
||||
# Pytest
|
||||
.pytest_cache/
|
||||
|
||||
# enviroment constants
|
||||
.envrc
|
33
backend/Dockerfile
Normal file
33
backend/Dockerfile
Normal file
@ -0,0 +1,33 @@
|
||||
# build stage
|
||||
FROM python:3.11 AS builder
|
||||
|
||||
# install PDM
|
||||
RUN pip install -U pip setuptools wheel
|
||||
RUN pip install pdm
|
||||
|
||||
# copy files
|
||||
COPY pyproject.toml pdm.lock README.md /backend/
|
||||
COPY install.sh /backend/
|
||||
COPY src/ /backend/src
|
||||
|
||||
# import ENV
|
||||
ARG ENV
|
||||
|
||||
# install dependencies and project into the local packages directory
|
||||
WORKDIR /backend
|
||||
RUN mkdir __pypackages__ && chmod u+x install.sh && ./install.sh
|
||||
|
||||
# run stage
|
||||
FROM python:3.11
|
||||
|
||||
# retrieve packages from build stage
|
||||
ENV PYTHONPATH=/backend/pkgs
|
||||
COPY --from=builder /backend/__pypackages__/3.11/lib /backend/pkgs
|
||||
|
||||
# retrieve executables
|
||||
COPY --from=builder /backend/__pypackages__/3.11/bin/* /bin/
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# set command/entrypoint, adapt to fit your needs
|
||||
CMD ["python3","-m", "uvicorn", "neo_neo_todo.main:app", "--reload"]
|
1
backend/README.md
Normal file
1
backend/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Backend Technical Write Up
|
7
backend/install.sh
Executable file
7
backend/install.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ${ENV} = "DEV" ]; then
|
||||
pdm sync --dev
|
||||
else
|
||||
pdm sync --prod --no-editable
|
||||
fi
|
0
pdm.lock → backend/pdm.lock
generated
0
pdm.lock → backend/pdm.lock
generated
@ -39,11 +39,17 @@ asyncio_mode = "auto"
|
||||
pythonpath = ["src"]
|
||||
|
||||
[tool.pdm.scripts]
|
||||
|
||||
# python code formatting
|
||||
format-black = "black src/ tests/"
|
||||
|
||||
# python code linting
|
||||
lint-ruff = "ruff check src/ tests/"
|
||||
|
||||
format = {composite = ["format-black"]}
|
||||
|
||||
lint = {composite = ["lint-ruff"]}
|
||||
|
||||
test = "pytest tests/"
|
||||
|
||||
start = "uvicorn neo_neo_todo.main:app --reload"
|
Loading…
x
Reference in New Issue
Block a user