-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The final build of the docker image in CI
- Loading branch information
Showing
8 changed files
with
109 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
src/.pdm-python | ||
**/.pdm-python | ||
**/node_modules | ||
**/.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM node:20 as frontend-builder | ||
|
||
RUN corepack enable && yarn set version berry | ||
|
||
WORKDIR /app/frontend | ||
|
||
COPY ./frontend/package.json ./frontend/yarn.lock ./ | ||
COPY ./frontend/.yarn ./.yarn | ||
COPY ./frontend/.yarnrc.yml ./ | ||
|
||
RUN yarn install | ||
|
||
COPY ./frontend . | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN yarn build --mode production | ||
|
||
FROM python:3.11-slim as backend-builder | ||
|
||
RUN pip install pdm | ||
|
||
WORKDIR /app | ||
|
||
COPY ./backend/pyproject.toml ./backend/pdm.lock ./ | ||
|
||
RUN pdm install --prod | ||
|
||
COPY ./backend/src ./src | ||
COPY --from=frontend-builder /app/frontend/dist ./src/static | ||
|
||
WORKDIR /app/src | ||
|
||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["pdm", "run", "uvicorn", "main:app", "--host=0.0.0.0", "--port=8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def join_paths_safely(base_path: str, relative_path: str) -> str: | ||
""" | ||
Joins a base path and a relative path safely, ensuring only one slash between them. | ||
This function ensures that there's exactly one slash between the base and relative paths, | ||
regardless of whether the base path ends with a slash or the relative path starts with one. | ||
Parameters: | ||
base_path (str): The base path to be joined. | ||
relative_path (str): The relative path to append to the base path. | ||
Returns: | ||
str: The resulting path after safely joining the base and relative paths. | ||
Examples: | ||
>>> join_paths_safely('/base/path/', '/relative/path') | ||
'/base/path/relative/path' | ||
>>> join_paths_safely('/base/path', 'relative/path') | ||
'/base/path/relative/path' | ||
""" | ||
# Remove the trailing slash from the base path if it exists, and add a leading slash to the relative path if it's missing | ||
# Then concatenate the paths | ||
return base_path.rstrip('/') + '/' + relative_path.lstrip('/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters