Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/docker-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `bambu`.
on:
workflow_dispatch:
push:
branches: ["bambu"]
tags:
- "*"

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/webcam-bambu
IMAGE_TAG: latest
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64,amd64"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@83a00bc1ab5ded6580f31df1c49e6aaa932d840d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha

# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3-slim

EXPOSE 8080

WORKDIR /usr/src/app

RUN pip install --no-cache-dir pillow

COPY webcam.py ./
COPY SourceCodePro-Regular.ttf ./

ENV HOSTNAME=localhost
ENV ACCESS_CODE=111111
ENV WIDTH=1920
ENV HEIGHT=1080
ENV ENCODEWAIT=0.5
ENV ROTATE=-1

ENTRYPOINT python ./webcam.py --hostname $HOSTNAME --password $ACCESS_CODE --width $WIDTH --height $HEIGHT --port 8080 --encodewait $ENCODEWAIT --rotate $ROTATE --loghttp

2 changes: 1 addition & 1 deletion webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def sendSnapshot(self, rotate=-1):

draw = ImageDraw.Draw(jpg)

message = f"{socket.getnameinfo((self.client_address[0], 0), 0)[0]}\n{datetime.datetime.now()}"
message = f"{datetime.datetime.now()}"

bbox = draw.textbbox((0, fmD), message, font=fpsFont)
draw.rectangle(bbox, fill="black")
Expand Down