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
51 changes: 51 additions & 0 deletions .github/workflows/publish-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Publish :latest docker tag"

# Trigger the workflow on any commit or merge to the main branch
on:
push:
branches:
- main
- ci/refactore # TODO: remove it
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the build is failing because sed uses / to determine different parts of the command. It fails on this command sed -i "s/%version%/$VERSION/g" docker/web/***/web/templates/footer.html when trying to update the version shown in the footer, but, because the branch is "ci/refactore" it fails as it tries to parse "refactore" as an option to the sed command s as per sed -i "s/%version%/ci/refactore/g" docker/web/***/web/templates/footer.html My pruposal is to change the sed command to sed -i "s|%version%|$VERSION|g" docker/web/***/web/templates/footer.html (ie. use pipes instead of / as separators, we are much more unlikely to want to have a pipe in the version than a / either way).


env:
DOCKER_IMAGE_REGISTRY_PATH: nspanelmanager/nspanelmanager
DOCKER_TAG: test # TODO: change it after proper testing (after merge)

jobs:
publish:
runs-on: ubuntu-24.04

permissions:
contents: read

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Get Git commit timestamps
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV

- name: Set up QEMU (required for Buildx)
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0

- name: Login to DockerHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push multi-arch image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: ./docker/Dockerfile
# note: platforms list: https://github.com/docker/setup-qemu-action qemu-arm,qemu-aarch64
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:${{ env.DOCKER_TAG }}
build-args: |
GITHUB_REF_NAME=${{ github.ref_name }}
env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
27 changes: 18 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM --platform=$BUILDPLATFORM python:3.11 AS build
# syntax=docker/dockerfile:1
# check=error=true

FROM python:3.11 AS build
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG no_mqttmanager_build
Expand All @@ -7,7 +10,7 @@ WORKDIR /MQTTManager
SHELL ["/bin/bash", "-c"]

RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"
COPY MQTTManager/ /MQTTManager/
COPY docker/MQTTManager/ /MQTTManager/

# Only build MQTTManager during Docker build if is is not a devel mode.
RUN if [ "$IS_DEVEL" != "yes" ]; then apt-get update \
Expand All @@ -24,14 +27,22 @@ RUN if [ -z "$no_mqttmanager_build" ]; then /bin/bash /MQTTManager/compile_mqttm
FROM python:3.11
ARG no_mqttmanager_build
ARG IS_DEVEL
ARG GITHUB_REF_NAME
ENV VERSION=$GITHUB_REF_NAME
WORKDIR /usr/src/app
SHELL ["/bin/bash", "-c"]

COPY web/ /usr/src/app/
COPY nginx/sites-enabled/ /etc/nginx/sites-enabled/
COPY nginx/sites-templates/ /etc/nginx/sites-templates/
COPY docker/web/ /usr/src/app/
COPY docker/nginx/sites-enabled/ /etc/nginx/sites-enabled/
COPY docker/nginx/sites-templates/ /etc/nginx/sites-templates/
COPY --from=build /MQTTManager/build /MQTTManager/build

COPY docker/web/nspanelmanager/web/templates/footer_template.html docker/web/nspanelmanager/web/templates/footer.html
COPY docs/tex/manual.pdf docker/web/nspanelmanager/manual.pdf

RUN sed -i "s|%version%|$VERSION|g" docker/web/nspanelmanager/web/templates/footer.html


# Update container
RUN apt-get update \
&& apt-get -y upgrade
Expand All @@ -51,15 +62,13 @@ RUN if [ "$IS_DEVEL" == "yes" ]; then conan profile detect --force && echo 'core

# Install software needed to build and run the manager
RUN apt-get install -y --no-install-recommends \
postgresql-client curl inotify-tools net-tools nginx build-essential
# && rm -rf /var/lib/apt/lists/*
postgresql-client curl inotify-tools net-tools nginx build-essential \
&& rm -rf /var/lib/apt/lists/*

RUN pip install -r requirements.txt # Install python packages
#RUN /bin/bash /MQTTManager/install_cmake.sh # Install cmake from source as it's only available for x86_64 and armv8 in repo

RUN echo "alias ll='ls -lh --color=auto'" >> /etc/bash.bashrc

#RUN if [ -z "$no_mqttmanager_build" ]; then /bin/bash /usr/src/app/make_mqttmanager.sh && /bin/bash /MQTTManager/cleanup_build.sh; else echo "Not building MQTTManager."; fi

EXPOSE 8000
CMD ["/bin/bash", "./run_uwsgi.sh"]
Loading