-
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.
Merge pull request #142 from European-XFEL/feat/add-container-cd
Feat/add container cd
- Loading branch information
Showing
2 changed files
with
125 additions
and
0 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,56 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'master' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=pep440,pattern={{version}} # '{version}' on tag | ||
type=edge,branch=master # 'edge' on push to master branch | ||
type=ref,event=pr # 'pr-{pr-no}' on pr | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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,69 @@ | ||
FROM debian:bookworm AS build | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# install build dependencies | ||
RUN set -eux; \ | ||
apt update; \ | ||
apt install -y --no-install-recommends \ | ||
g++ \ | ||
gcc \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-venv \ | ||
# include pyqt deps so pip does not install them later | ||
python3-pyqt5 \ | ||
python3-pyqt5.qsci \ | ||
python3-pyqt5.qtsvg \ | ||
; \ | ||
apt list --installed $(apt-mark showmanual) > /.apt-deps-build | ||
|
||
COPY pyproject.toml /src/pyproject.toml | ||
|
||
# set up venv and python dependencies | ||
RUN set -eux; \ | ||
mkdir -p /src/damnit; \ | ||
# install dependencies w/o installing package itself | ||
# https://github.com/pypa/pip/issues/11440 | ||
echo '"""Hello"""' > /src/damnit/__init__.py; \ | ||
echo '__version__="0.0.0"' >> /src/damnit/__init__.py; \ | ||
python3 -m venv --system-site-packages /app; \ | ||
/app/bin/python3 -m pip install /src; \ | ||
/app/bin/python3 -m pip uninstall -y damnit; \ | ||
/app/bin/python3 -m pip freeze > /.python-deps-build | ||
|
||
FROM debian:bookworm-slim | ||
|
||
COPY --from=build /app /app | ||
COPY --from=build /.apt-deps-build /.apt-deps-build | ||
COPY --from=build /.python-deps-build /.python-deps-build | ||
|
||
ENV PATH="/app/bin:${PATH}" | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
WORKDIR /app | ||
|
||
# install runtime dependencies | ||
RUN set -eux; \ | ||
apt update; \ | ||
apt install -y --no-install-recommends \ | ||
ca-certificates \ | ||
python3-pyqt5 \ | ||
python3-pyqt5.qsci \ | ||
python3-pyqt5.qtsvg \ | ||
; \ | ||
apt clean; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ | ||
apt list --installed $(apt-mark showmanual) > /.apt-deps-runtime | ||
|
||
# install DAMNIT | ||
COPY . /src | ||
RUN set -eux; \ | ||
/app/bin/python3 -m pip install -vv --no-cache-dir /src; \ | ||
/app/bin/python3 -m pip freeze > /.python-deps-runtime; \ | ||
python3 -m pip check; \ | ||
python3 -c "import damnit; print(damnit.__version__)" | ||
|
||
CMD ["/app/bin/amore-proto", "gui"] | ||
|