Merge pull request 'docker multistage build' (#13) from feature/docker into dev
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
+28
-4
@@ -1,4 +1,5 @@
|
|||||||
# --- Stage 1: Python Backend dev ---
|
# --- Stage 1: Python Backend dev ---
|
||||||
|
|
||||||
FROM python:3.14-slim AS dev
|
FROM python:3.14-slim AS dev
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="The-DisExcel-project-dev"
|
LABEL org.opencontainers.image.title="The-DisExcel-project-dev"
|
||||||
@@ -14,6 +15,28 @@ RUN pip install --no-cache-dir --break-system-packages poetry \
|
|||||||
&& poetry config virtualenvs.create false \
|
&& poetry config virtualenvs.create false \
|
||||||
&& poetry install --no-root --no-interaction
|
&& poetry install --no-root --no-interaction
|
||||||
|
|
||||||
|
|
||||||
|
# --- Stage 1: Python Backend builder ---
|
||||||
|
|
||||||
|
FROM python:3.14-slim AS builder
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title="The-DisExcel-project-dev"
|
||||||
|
LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_DisExcel_project"
|
||||||
|
|
||||||
|
WORKDIR /home/excel-project
|
||||||
|
|
||||||
|
ENV VIRTUAL_ENV=/opt/venv
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
RUN python -m venv "$VIRTUAL_ENV"
|
||||||
|
|
||||||
|
COPY pyproject.toml poetry.lock ./
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir poetry \
|
||||||
|
&& poetry config virtualenvs.create false \
|
||||||
|
&& poetry install --no-root --no-interaction --only main \
|
||||||
|
&& pip uninstall -y poetry poetry-core poetry-plugin-export
|
||||||
|
|
||||||
# --- Stage 2: Python Backend prod ---
|
# --- Stage 2: Python Backend prod ---
|
||||||
|
|
||||||
FROM python:3.14-slim AS prod
|
FROM python:3.14-slim AS prod
|
||||||
@@ -23,15 +46,16 @@ LABEL org.opencontainers.image.source="https://git.homyk.space/MH.Dmitrii/The_Di
|
|||||||
|
|
||||||
WORKDIR /home/excel-project
|
WORKDIR /home/excel-project
|
||||||
|
|
||||||
|
ENV VIRTUAL_ENV=/opt/venv
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
COPY --from=builder /opt/venv /opt/venv
|
||||||
|
|
||||||
COPY pyproject.toml poetry.lock main.py docker/entrypoint.sh alembic.ini ./
|
COPY pyproject.toml poetry.lock main.py docker/entrypoint.sh alembic.ini ./
|
||||||
COPY src/ ./src/
|
COPY src/ ./src/
|
||||||
|
|
||||||
RUN chmod +x ./entrypoint.sh
|
RUN chmod +x ./entrypoint.sh
|
||||||
|
|
||||||
RUN pip install --no-cache-dir --break-system-packages poetry \
|
|
||||||
&& poetry config virtualenvs.create false \
|
|
||||||
&& poetry install --no-root --no-interaction --only main
|
|
||||||
|
|
||||||
RUN groupadd --gid 1000 appuser \
|
RUN groupadd --gid 1000 appuser \
|
||||||
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser \
|
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser \
|
||||||
&& chown -R appuser:appuser /home/excel-project
|
&& chown -R appuser:appuser /home/excel-project
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ class Seed:
|
|||||||
|
|
||||||
existing = (await session.execute(select(User).limit(1))).scalar_one_or_none()
|
existing = (await session.execute(select(User).limit(1))).scalar_one_or_none()
|
||||||
if existing is not None:
|
if existing is not None:
|
||||||
print("Seed skipped: one user is already exist")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
admin_permission = Permissions(permission="admin")
|
admin_permission = Permissions(permission="admin")
|
||||||
|
|||||||
Reference in New Issue
Block a user