-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
51 additions
and
27 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,30 +1,47 @@ | ||
name: Create and publish a package | ||
name: Push Docker Image to GitHub Packages | ||
on: | ||
push: | ||
branches: ["master"] | ||
branches: | ||
- master | ||
- container | ||
tags: | ||
- "*" | ||
pull_request: | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
IMAGE_NAME: python-snap7 | ||
# | ||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-20.04 | ||
push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
# | ||
steps: | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Build container image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Build and push container image | ||
run: | | ||
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# when the branch is master, replace master with latest | ||
[ "$VERSION" == "master" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
# Build and Publish container image | ||
docker buildx build --push \ | ||
--tag $IMAGE_ID:$VERSION \ | ||
--platform linux/amd64,linux/arm/v7,linux/arm64 . |
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,10 +1,17 @@ | ||
FROM ubuntu:20.04 | ||
FROM ubuntu:24.04 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/gijzelaerr/python-snap7 | ||
LABEL org.opencontainers.image.description="The snap7 library is used to communicate with Siemens S7 PLCs. This is a Python wrapper for the snap7 library." | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
RUN apt update \ | ||
&& apt install -y software-properties-common python3-pip \ | ||
&& apt install -y software-properties-common python3-pip python3-venv \ | ||
&& add-apt-repository ppa:gijzelaar/snap7 \ | ||
&& apt update \ | ||
&& apt install -y libsnap7-dev libsnap7-1 | ||
ADD . /code | ||
WORKDIR /code | ||
RUN pip3 install . | ||
WORKDIR /venv | ||
RUN python3 -m venv /venv | ||
RUN . /venv/bin/activate | ||
RUN /venv/bin/pip install /code |