-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVEMENT] - add scheduler Docker image (#148)
- Loading branch information
1 parent
f18e073
commit f8103ae
Showing
10 changed files
with
233 additions
and
97 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Scheduler docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
name: Build & push scheduler image to Dockerhub | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'MobileTeleSystems/syncmaster' # prevent running on forks | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set tag | ||
id: set_tag | ||
run: | | ||
if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "develop" ]]; then | ||
echo "TAG=mtsrus/syncmaster-scheduler:develop" >> $GITHUB_ENV | ||
elif [[ "${{ github.ref_type }}" == "tag" ]]; then | ||
echo "TAG=mtsrus/syncmaster-scheduler:latest,mtsrus/syncmaster-scheduler:${{ github.ref_name }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build scheduler image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
tags: ${{ env.TAG }} | ||
context: . | ||
target: prod | ||
file: docker/Dockerfile.scheduler | ||
pull: true | ||
push: true | ||
cache-to: type=inline | ||
cache-from: mtsrus/syncmaster-scheduler:develop | ||
platforms: | | ||
linux/amd64 | ||
linux/arm64/v8 | ||
provenance: mode=max | ||
|
||
- name: Convert README to Markdown | ||
uses: docker://pandoc/core:2.9 | ||
with: | ||
args: >- | ||
--output=README.md | ||
--from=rst | ||
--to=gfm | ||
--wrap=none | ||
README.rst | ||
- name: Update DockerHub Description | ||
uses: peter-evans/dockerhub-description@v4 | ||
if: github.ref_type == 'tag' | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
# this requires token with read+write+delete permissions. read+write is not enough! | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
repository: mtsrus/syncmaster-scheduler | ||
short-description: ${{ github.event.repository.description }} | ||
enable-url-completion: true |
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
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
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,28 @@ | ||
FROM python:3.12-slim AS base | ||
|
||
RUN apt-get update && apt-get install -y curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - \ | ||
&& ln -s /root/.local/bin/poetry /usr/local/bin/poetry \ | ||
&& poetry config virtualenvs.create false | ||
|
||
WORKDIR /app | ||
ENV PYTHONPATH=/app | ||
|
||
COPY ./pyproject.toml ./poetry.lock* /app/ | ||
|
||
RUN pip install --upgrade pip setuptools wheel packaging | ||
RUN poetry install --no-root --extras "scheduler" --without test,docs,dev | ||
|
||
COPY ./docker/entrypoint_scheduler.sh /app/entrypoint.sh | ||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
|
||
FROM base AS prod | ||
|
||
COPY ./syncmaster/ /app/syncmaster/ | ||
|
||
FROM base as test | ||
Check warning on line 25 in docker/Dockerfile.scheduler GitHub Actions / Build & push scheduler image to DockerhubThe 'as' keyword should match the case of the 'from' keyword
|
||
|
||
RUN poetry install --no-root --all-extras --with test --without docs,dev | ||
RUN sed -i 's/python -m/coverage run -m/g' /app/entrypoint.sh |
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,4 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
exec python -m syncmaster.scheduler "$@" |
Oops, something went wrong.