Compare commits
3
Commits
8db61b2b8a
...
c6f4c81ddd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f4c81ddd | ||
|
|
1f4f9949fe | ||
|
|
8c5b58ebf3 |
@@ -30,22 +30,44 @@ jobs:
|
||||
name: Build and Publish
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
-
|
||||
dockerfile: ./Dockerfile.web_ui
|
||||
image: ${{ vars.docker_repo_url }}/${{ gitea.repository }}/web_ui
|
||||
# -
|
||||
# dockerfile: ./model/Dockerfile
|
||||
# image: ${{ vars.docker_repo_url }}/${{ gitea.repository }}/model
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
-
|
||||
name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
- name: Set Environment Variables
|
||||
-
|
||||
name: Set Environment Variables
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short ${{ gitea.sha }} )" >> "$GITHUB_ENV"
|
||||
- name: Show Environment Variables
|
||||
-
|
||||
name: Show Environment Variables
|
||||
run: |
|
||||
echo "DOCKER_REPO_URL: ${{ vars.docker_repo_url }}"
|
||||
echo "REPOSITORY: ${{ gitea.repository }}"
|
||||
echo "COMMIT_SHA: ${{ env.sha_short }}"
|
||||
- name: Build and Push Image
|
||||
-
|
||||
name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ matrix.image }}
|
||||
-
|
||||
name: Build and Push Image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./web_ui/
|
||||
context: .
|
||||
file: ${{ matrix.dockerfile }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ vars.docker_repo_url }}/${{ gitea.repository }}/web_ui:${{ env.sha_short }}
|
||||
${{ vars.docker_repo_url }}/${{ gitea.repository }}/web_ui:latest
|
||||
${{ matrix.image }}:${{ env.sha_short }}
|
||||
${{ matrix.image }}:latest
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# build stage
|
||||
FROM python:3.12-slim-bookworm as BUILDER
|
||||
|
||||
# set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=off \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=ON \
|
||||
PIP_DEFAULT_TIMEOUT=100 \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
POETRY_HOME=/etc/poetry \
|
||||
POETRY_VERSION=1.7.1 \
|
||||
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
||||
POETRY_VIRTUALENVS_CREATE=1 \
|
||||
POETRY_NO_INTERACTION=1 \
|
||||
POETRY_CACHE_DIR=/tmp/poetry_cache \
|
||||
APP_HOME=/home/app
|
||||
|
||||
# update system
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
curl \
|
||||
&& apt-get clean
|
||||
|
||||
# install poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
ENV PATH="${POETRY_HOME}/bin:$PATH"
|
||||
|
||||
# install runtime dependencies
|
||||
WORKDIR ${APP_HOME}
|
||||
COPY ./poetry.lock ./pyproject.toml ./
|
||||
RUN --mount=type=cache,target=${POETRY_CACHE_DIR} poetry install \
|
||||
--with shared,web_ui
|
||||
|
||||
# final stage
|
||||
FROM python:3.12-slim-bookworm
|
||||
|
||||
# copy virtualenv made by poetry
|
||||
ENV APP_HOME=/home/app \
|
||||
VIRTUAL_ENV=/home/app/.venv
|
||||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
||||
|
||||
# create home directory and app user
|
||||
RUN mkdir -p /home/app && \
|
||||
addgroup --system app && \
|
||||
adduser --system --group app
|
||||
|
||||
# add code while changing ownership
|
||||
WORKDIR $APP_HOME
|
||||
COPY --chown=app:app ./shared ./shared
|
||||
COPY --chown=app:app ./web_ui/src ./src
|
||||
|
||||
# change to the app user
|
||||
USER app
|
||||
|
||||
ENTRYPOINT [ "gunicorn", "src.main:server", "-b", "0.0.0.0:8050" ]
|
||||
+3
-3
@@ -29,7 +29,7 @@ ENV PATH="${POETRY_HOME}/bin:$PATH"
|
||||
|
||||
# install runtime dependencies
|
||||
WORKDIR ${APP_HOME}
|
||||
COPY poetry.lock pyproject.toml ./
|
||||
COPY ../poetry.lock ../pyproject.toml ./
|
||||
RUN --mount=type=cache,target=${POETRY_CACHE_DIR} poetry install \
|
||||
--with shared,web_ui
|
||||
|
||||
@@ -49,8 +49,8 @@ RUN mkdir -p /home/app && \
|
||||
|
||||
# add code while changing ownership
|
||||
WORKDIR $APP_HOME
|
||||
COPY --chown=app:app ./shared ./shared
|
||||
COPY --chown=app:app ./web_ui/src ./src
|
||||
COPY --chown=app:app ../shared ./shared
|
||||
COPY --chown=app:app ./src ./src
|
||||
|
||||
# change to the app user
|
||||
USER app
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
services:
|
||||
web:
|
||||
web_ui:
|
||||
image: visual_critical_discourse_analysis:test
|
||||
container_name: visual_critical_discourse_analysis_alone
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: ./web_ui/Dockerfile
|
||||
dockerfile: Dockerfile.web_ui
|
||||
ports:
|
||||
- 8050:8050
|
||||
env_file:
|
||||
|
||||
Reference in New Issue
Block a user