diff --git a/.github/actions/build-bareos-app/action.yml b/.github/actions/build-bareos-app/action.yml index 04102925..478b6670 100644 --- a/.github/actions/build-bareos-app/action.yml +++ b/.github/actions/build-bareos-app/action.yml @@ -1,6 +1,12 @@ name: 'build-bareos-app' description: 'Build Bareos app images' author: 'Barcus' +inputs: + registry: + description: 'Registry URL' + required: true runs: using: 'docker' image: 'Dockerfile' + args: + - ${{ inputs.registry }} diff --git a/.github/actions/build-bareos-app/entrypoint.sh b/.github/actions/build-bareos-app/entrypoint.sh index 55d04820..f8c17f06 100755 --- a/.github/actions/build-bareos-app/entrypoint.sh +++ b/.github/actions/build-bareos-app/entrypoint.sh @@ -32,7 +32,7 @@ while read app version arch app_path ; do --build-arg VCS_REF=$(git rev-parse --short HEAD) \ --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ --build-arg NAME="${GITHUB_REPOSITORY}-${app}" \ - --output "type=docker,dest=${workdir}/bareos-${app}-${tag}.tar,name=${GITHUB_REPOSITORY}-${app}:${tag}" \ + --output "type=docker,dest=${workdir}/bareos-${app}-${tag}.tar,name=${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${app}:${tag}" \ "${app_path}" if [[ $? -ne 0 ]] ; then diff --git a/.github/actions/prepare-bareos-app/entrypoint.sh b/.github/actions/prepare-bareos-app/entrypoint.sh index b973fbd4..a73eab2f 100755 --- a/.github/actions/prepare-bareos-app/entrypoint.sh +++ b/.github/actions/prepare-bareos-app/entrypoint.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash BUILDX_VER='v0.5.1' -latest_ubuntu='21' +latest_ubuntu='24' latest_alpine='22' -latest_api='22' +latest_api='24' build_file="${GITHUB_WORKSPACE}/build/app_build.txt" tag_file="${GITHUB_WORKSPACE}/build/tag_build.txt" diff --git a/.github/actions/push-bareos-app/action.yml b/.github/actions/push-bareos-app/action.yml index 6bfbf692..6b5a4241 100644 --- a/.github/actions/push-bareos-app/action.yml +++ b/.github/actions/push-bareos-app/action.yml @@ -3,10 +3,18 @@ description: 'Push Bareos docker images to Docker Hub' author: 'Barcus' inputs: docker_pass: - description: 'Docker Hub password' + description: 'Registry Password' required: true + docker_user: + description: 'Registry Username' + required: true + registry: + description: 'Registry URL' + required: false runs: using: 'docker' image: 'Dockerfile' args: + - ${{ inputs.docker_user }} - ${{ inputs.docker_pass }} + - ${{ inputs.registry }} diff --git a/.github/actions/push-bareos-app/entrypoint.sh b/.github/actions/push-bareos-app/entrypoint.sh index a8d49745..5d1970d0 100755 --- a/.github/actions/push-bareos-app/entrypoint.sh +++ b/.github/actions/push-bareos-app/entrypoint.sh @@ -15,7 +15,7 @@ done echo ::endgroup:: # Connect Docker Hub -docker login -u 'barcus' -p "${INPUT_DOCKER_PASS}" +docker login "${INPUT_REGISTRY}" -u "${INPUT_DOCKER_USER}" -p "${INPUT_DOCKER_PASS}" # Push tags and manfiests echo ::group::Push build tags @@ -27,10 +27,10 @@ while read line ; do re='^[0-9]+-alpine.*$' if [[ $version =~ $re ]] ; then build_tag="${version}-${arch}" - rm_tag="$rm_tag ${GITHUB_REPOSITORY}-${app}:${build_tag}" + rm_tag="$rm_tag ${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${app}:${build_tag}" fi # Push build tags - docker push "${GITHUB_REPOSITORY}-${app}:${build_tag}" + docker push "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${app}:${build_tag}" done < "${workdir}/app_build.txt" echo ::endgroup:: @@ -38,16 +38,16 @@ echo ::group::Push additional tags while read build_app s_tag t_tag ; do # Push additional tags for Ubuntu if [[ $s_tag =~ ^[a-z0-9]+-ubuntu.*$ ]]; then - docker tag "${GITHUB_REPOSITORY}-${build_app}:${s_tag}" \ - "${GITHUB_REPOSITORY}-${build_app}:${t_tag}" - docker push "${GITHUB_REPOSITORY}-${build_app}:${t_tag}" + docker tag "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${s_tag}" \ + "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${t_tag}" + docker push "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${t_tag}" fi # Create and push manifest for Alpine (arm64 + amd64) if [[ $s_tag =~ ^[a-z0-9]+-alpine.*$ ]]; then - docker manifest create "${GITHUB_REPOSITORY}-${build_app}:${t_tag}" \ - "${GITHUB_REPOSITORY}-${build_app}:${s_tag}-amd64" \ - "${GITHUB_REPOSITORY}-${build_app}:${s_tag}-arm64" - docker manifest push "${GITHUB_REPOSITORY}-${build_app}:${t_tag}" + docker manifest create "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${t_tag}" \ + "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${s_tag}-amd64" \ + "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${s_tag}-arm64" + docker manifest push "${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${build_app}:${t_tag}" fi done < "${workdir}/tag_build.txt" echo ::endgroup:: diff --git a/.github/actions/test-bareos-app/action.yml b/.github/actions/test-bareos-app/action.yml index d2216534..9b6e0f11 100644 --- a/.github/actions/test-bareos-app/action.yml +++ b/.github/actions/test-bareos-app/action.yml @@ -1,6 +1,12 @@ name: 'test-bareos-app' description: 'Test Bareos docker images' author: 'Barcus' +inputs: + registry: + description: 'Registry URL' + required: true runs: using: 'docker' image: 'Dockerfile' + args: + - ${{ inputs.registry }} diff --git a/.github/actions/test-bareos-app/entrypoint.sh b/.github/actions/test-bareos-app/entrypoint.sh index af174550..717d3aa3 100755 --- a/.github/actions/test-bareos-app/entrypoint.sh +++ b/.github/actions/test-bareos-app/entrypoint.sh @@ -28,10 +28,16 @@ while read app version arch path ; do # Define args and command if [[ $version =~ $re_alpine ]] ; then build_tag="${version}-${arch}" - alpine_pkg='bareos' - [[ "$app" == "webui" ]] && alpine_pkg='bareos-webui' - CMD="apk list --installed $alpine_pkg" + + if [[ "$app" == "api" ]] ; then + CMD="python -m pip show bareos-restapi | grep 'Version:' | awk '{print $2}'" + elif [[ "$app" == "webui" ]] ; then + CMD="apk list --installed bareos-webui" + else + CMD="apk list --installed bareos" + fi fi + if [[ $version =~ $re_ubuntu ]] ; then CMD="dpkg-query --showformat=\${Version} --show bareos-${app}" fi @@ -48,7 +54,7 @@ while read app version arch path ; do # Run docker and check version img_version=$(docker run -t --rm ${ARGS} \ - ${GITHUB_REPOSITORY}-${app}:${build_tag} \ + ${INPUT_REGISTRY}/${GITHUB_REPOSITORY}-${app}:${build_tag} \ ${CMD} | tail -1) if [[ $version =~ $re_alpine ]] ; then diff --git a/.github/workflows/ci-api.yml b/.github/workflows/ci-api.yml index e236c85f..39904f41 100644 --- a/.github/workflows/ci-api.yml +++ b/.github/workflows/ci-api.yml @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/ci-bareos-app.tmpl b/.github/workflows/ci-bareos-app.tmpl index 6af69c1c..aa6c4611 100644 --- a/.github/workflows/ci-bareos-app.tmpl +++ b/.github/workflows/ci-bareos-app.tmpl @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/ci-client.yml b/.github/workflows/ci-client.yml index 8948346d..53fac004 100644 --- a/.github/workflows/ci-client.yml +++ b/.github/workflows/ci-client.yml @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/ci-director.yml b/.github/workflows/ci-director.yml index ba7f90f0..d25dd9c1 100644 --- a/.github/workflows/ci-director.yml +++ b/.github/workflows/ci-director.yml @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/ci-storage.yml b/.github/workflows/ci-storage.yml index 32a7a5f2..53e27e7c 100644 --- a/.github/workflows/ci-storage.yml +++ b/.github/workflows/ci-storage.yml @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/ci-webui.yml b/.github/workflows/ci-webui.yml index 88f2bf1a..24931d84 100644 --- a/.github/workflows/ci-webui.yml +++ b/.github/workflows/ci-webui.yml @@ -61,6 +61,8 @@ jobs: - name: Build images uses: ./.github/actions/build-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} - name: Upload artifact uses: actions/upload-artifact@v4 @@ -90,6 +92,8 @@ jobs: - name: Load and test images uses: ./.github/actions/test-bareos-app + with: + registry: ${{ secrets.REGISTRY_URL }} deploy: needs: test @@ -111,3 +115,5 @@ jobs: uses: ./.github/actions/push-bareos-app with: docker_pass: ${{ secrets.DOCKER_PASS }} + docker_user: ${{ secrets.DOCKER_USER }} + registry: ${{ secrets.REGISTRY_URL }} diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 00000000..2a1042ab --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,17 @@ +name: Claude Code +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] +jobs: + claude: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/push-readme.yml b/.github/workflows/push-readme.yml index 664c4a0a..276a2133 100644 --- a/.github/workflows/push-readme.yml +++ b/.github/workflows/push-readme.yml @@ -23,6 +23,6 @@ jobs: - name: Update Docker Hub description uses: peter-evans/dockerhub-description@v4.0.0 env: - DOCKERHUB_USERNAME: barcus + DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USER }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASS }} - DOCKERHUB_REPOSITORY: barcus/bareos-${{ matrix.module }} + DOCKERHUB_REPOSITORY: ${{ secrets.REGISTRY_URL }}/bareos/bareos-${{ matrix.module }} diff --git a/.github/workflows/test-n-lint.yml b/.github/workflows/test-n-lint.yml index c1819165..990867c5 100644 --- a/.github/workflows/test-n-lint.yml +++ b/.github/workflows/test-n-lint.yml @@ -25,7 +25,7 @@ jobs: done lint-markdown: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/api/24-alpine/Dockerfile b/api/24-alpine/Dockerfile new file mode 100644 index 00000000..3945d8a6 --- /dev/null +++ b/api/24-alpine/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.10-alpine + +LABEL maintainer="barcus@tou.nu" + +ARG BUILD_DATE +ARG NAME +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$NAME \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/barcus/bareos" \ + org.label-schema.version=$VERSION + +RUN pip install --no-cache-dir --upgrade pip==22.0.4 + +RUN adduser -D bareos +USER bareos +WORKDIR /home/bareos + +ENV PATH="/home/bareos/.local/bin:${PATH}" +RUN pip install --no-cache-dir "bareos-restapi>=24*,<25*" + +COPY --chown=bareos docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod a+x /docker-entrypoint.sh + +EXPOSE 8000 + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["uvicorn","--log-level", "debug", "--host", "0.0.0.0", "bareos_restapi:app", "--reload"] diff --git a/api/24-alpine/docker-entrypoint.sh b/api/24-alpine/docker-entrypoint.sh new file mode 100644 index 00000000..c9eb80ee --- /dev/null +++ b/api/24-alpine/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env ash +#set -x + +secret=`tr -cd "[:alnum:]" < /dev/urandom | fold -w30 | head -n1` + +# Generate api.ini config +cat < /home/bareos/api.ini +[Director] +Name=${BAREOS_DIR_HOST} +Address=${BAREOS_DIR_HOST} +Port=9101 + +[JWT] +secret_key = ${secret} +algorithm = HS256 +access_token_expire_minutes = 30 +EOF + +# Run Dockerfile CMD +exec "$@" diff --git a/client/21-alpine/Dockerfile b/client/21-alpine/Dockerfile index 4e73d3fc..45c65354 100644 --- a/client/21-alpine/Dockerfile +++ b/client/21-alpine/Dockerfile @@ -1,5 +1,5 @@ # Dockerfile Bareos client/file daemon -FROM alpine:3.16 +FROM alpine:3.17 LABEL maintainer="barcus@tou.nu" diff --git a/client/22-alpine/Dockerfile b/client/22-alpine/Dockerfile index ec1f6c8c..7f8c7801 100644 --- a/client/22-alpine/Dockerfile +++ b/client/22-alpine/Dockerfile @@ -1,5 +1,5 @@ # Dockerfile Bareos client/file daemon -FROM alpine:3.20 +FROM alpine:3.18 LABEL maintainer="barcus@tou.nu" diff --git a/client/24-ubuntu/Dockerfile b/client/24-ubuntu/Dockerfile new file mode 100644 index 00000000..a60cbc83 --- /dev/null +++ b/client/24-ubuntu/Dockerfile @@ -0,0 +1,44 @@ +# Dockerfile Bareos client/file daemon +FROM ubuntu:noble + +LABEL maintainer="barcus@tou.nu" + +ARG BUILD_DATE +ARG NAME +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$NAME \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/barcus/bareos" \ + org.label-schema.version=$VERSION + +ENV BAREOS_DAEMON_USER=bareos +ENV BAREOS_DAEMON_GROUP=bareos +ENV DEBIAN_FRONTEND=noninteractive +ENV BAREOS_KEY=http://download.bareos.org/current/xUbuntu_24.04/Release.key +ENV BAREOS_REPO=http://download.bareos.org/current/xUbuntu_24.04/ + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN apt-get update -qq \ + && apt-get -qq -y install --no-install-recommends curl tzdata gnupg gosu \ + && curl -Ls $BAREOS_KEY | gpg --dearmor -o /usr/share/keyrings/bareos.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/bareos.gpg] $BAREOS_REPO /" > /etc/apt/sources.list.d/bareos.list \ + && apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends \ + bareos-client mysql-client postgresql-client bareos-tools \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod a+x /docker-entrypoint.sh + +RUN tar czf /bareos-fd.tgz /etc/bareos/bareos-fd.d + +EXPOSE 9102 + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/bareos-fd", "-f"] diff --git a/client/24-ubuntu/docker-entrypoint.sh b/client/24-ubuntu/docker-entrypoint.sh new file mode 100644 index 00000000..3b1cbf43 --- /dev/null +++ b/client/24-ubuntu/docker-entrypoint.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +#set -x + +bareos_fd_config="/etc/bareos/bareos-fd.d/director/bareos-dir.conf" + +if [ "${FORCE_ROOT}" = true ]; then + BAREOS_DAEMON_USER='root' + BAREOS_DAEMON_GROUP='root' +fi + +if [ $(id -u) = '0' ]; then + [ -n "${PUID}" ] && usermod -u ${PUID} ${BAREOS_DAEMON_USER} + [ -n "${PGID}" ] && groupmod -g ${PGID} ${BAREOS_DAEMON_GROUP} + + if [ ! -f /etc/bareos/bareos-config.control ]; then + tar xzf /bareos-fd.tgz --backup=simple --suffix=.before-control + + # Force client/file daemon password + sed -i 's#Password = .*#Password = '\""${BAREOS_FD_PASSWORD}"\"'#' $bareos_fd_config + + # Control file + touch /etc/bareos/bareos-config.control + fi + + # Fix permissions + find /etc/bareos ! -user ${BAREOS_DAEMON_USER} -exec chown ${BAREOS_DAEMON_USER}:${BAREOS_DAEMON_GROUP} {} \; + chown -R ${BAREOS_DAEMON_USER}:${BAREOS_DAEMON_GROUP} /var/lib/bareos /var/log/bareos + + # Gosu + [ "${BAREOS_DAEMON_USER}" != 'root' ] && exec gosu "${BAREOS_DAEMON_USER}" "$BASH_SOURCE" "$@" +fi + +exec "$@" diff --git a/director-pgsql/21-alpine/Dockerfile b/director-pgsql/21-alpine/Dockerfile index 8ff82add..e1f95092 100644 --- a/director-pgsql/21-alpine/Dockerfile +++ b/director-pgsql/21-alpine/Dockerfile @@ -1,5 +1,5 @@ # Bareos director Dockerfile -FROM alpine:3.16 +FROM alpine:3.17 LABEL maintainer="barcus@tou.nu" diff --git a/director-pgsql/22-alpine/Dockerfile b/director-pgsql/22-alpine/Dockerfile index 2443d5de..3a0a7175 100644 --- a/director-pgsql/22-alpine/Dockerfile +++ b/director-pgsql/22-alpine/Dockerfile @@ -1,5 +1,5 @@ # Bareos director Dockerfile -FROM alpine:3.20 +FROM alpine:3.18 LABEL maintainer="barcus@tou.nu" diff --git a/director-pgsql/24-ubuntu/Dockerfile b/director-pgsql/24-ubuntu/Dockerfile new file mode 100644 index 00000000..7e94fc63 --- /dev/null +++ b/director-pgsql/24-ubuntu/Dockerfile @@ -0,0 +1,58 @@ +# Bareos director Dockerfile +FROM ubuntu:noble + +LABEL maintainer="barcus@tou.nu" + +ARG BUILD_DATE +ARG NAME +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$NAME \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/barcus/bareos" \ + org.label-schema.version=$VERSION + +ENV DEBIAN_FRONTEND=noninteractive +ENV BAREOS_KEY=http://download.bareos.org/current/xUbuntu_24.04/Release.key +ENV BAREOS_REPO=http://download.bareos.org/current/xUbuntu_24.04/ +ENV BAREOS_DPKG_CONF="bareos-database-common bareos-database-common" + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN apt-get update -qq \ + && apt-get -qq -y install --no-install-recommends curl tzdata gnupg \ + && curl -Ls $BAREOS_KEY | gpg --dearmor -o /usr/share/keyrings/bareos.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/bareos.gpg] $BAREOS_REPO /" > /etc/apt/sources.list.d/bareos.list \ + && echo "${BAREOS_DPKG_CONF}/dbconfig-install boolean false" \ + | debconf-set-selections \ + && echo "${BAREOS_DPKG_CONF}/install-error select ignore" \ + | debconf-set-selections \ + && echo "${BAREOS_DPKG_CONF}/database-type select pgsql" \ + | debconf-set-selections \ + && echo "${BAREOS_DPKG_CONF}/missing-db-package-error select ignore" \ + | debconf-set-selections \ + && echo 'postfix postfix/main_mailer_type select No configuration' \ + | debconf-set-selections \ + && apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends \ + bareos postgresql-client bareos-database-tools \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN tar czf /bareos-dir.tgz /etc/bareos + +COPY webhook-notify /usr/local/bin/webhook-notify +RUN chmod u+x /usr/local/bin/webhook-notify + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod u+x /docker-entrypoint.sh + +EXPOSE 9101 + +VOLUME /etc/bareos + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/bareos-dir", "-u", "bareos", "-f"] diff --git a/director-pgsql/24-ubuntu/docker-entrypoint.sh b/director-pgsql/24-ubuntu/docker-entrypoint.sh new file mode 100644 index 00000000..c6f3928e --- /dev/null +++ b/director-pgsql/24-ubuntu/docker-entrypoint.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash + +github_bareos='raw.githubusercontent.com/bareos/bareos' +webui_admin_conf='master/webui/install/bareos/bareos-dir.d/profile/webui-admin.conf' +admin_conf='master/webui/install/bareos/bareos-dir.d/console/admin.conf.example' + +if [ ! -f /etc/bareos/bareos-config.control ]; then + tar xzf /bareos-dir.tgz --backup=simple --suffix=.before-control + + # Download default admin profile config + if [ ! -f /etc/bareos/bareos-dir.d/profile/webui-admin.conf ]; then + curl --silent --insecure "https://${github_bareos}/${webui_admin_conf}" \ + --output /etc/bareos/bareos-dir.d/profile/webui-admin.conf + fi + + # Download default webUI admin config + if [ ! -f /etc/bareos/bareos-dir.d/console/admin.conf ]; then + curl --silent --insecure "https://${github_bareos}/${admin_conf}" \ + --output /etc/bareos/bareos-dir.d/console/admin.conf + fi + + # Update bareos-director configs + # Director / mycatalog & mail report + sed -i 's#dbuser = "bareos"#dbuser = '\"${DB_USER}\"'#' \ + /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf + sed -i 's#dbpassword = ""#dbpassword = '\"${DB_PASSWORD}\"'#' \ + /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf + sed -i 's#dbname = "bareos"#dbname = '\"${DB_NAME}\"'\n dbaddress = '\"${DB_HOST}\"'\n dbport = '\"${DB_PORT}\"'#' \ + /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf + [ -n "${SENDER_MAIL}" ] && sed -i "s#<%r#<${SENDER_MAIL}#g" \ + /etc/bareos/bareos-dir.d/messages/Daemon.conf + sed -i "s#/usr/bin/bsmtp -h localhost#/usr/bin/bsmtp -h ${SMTP_HOST}#" \ + /etc/bareos/bareos-dir.d/messages/Daemon.conf + sed -i "s#mail = root#mail = ${ADMIN_MAIL}#" \ + /etc/bareos/bareos-dir.d/messages/Daemon.conf + [ -n "${SENDER_MAIL}" ] && sed -i "s#<%r#<${SENDER_MAIL}#g" \ + /etc/bareos/bareos-dir.d/messages/Standard.conf + sed -i "s#/usr/bin/bsmtp -h localhost#/usr/bin/bsmtp -h ${SMTP_HOST}#" \ + /etc/bareos/bareos-dir.d/messages/Standard.conf + sed -i "s#mail = root#mail = ${ADMIN_MAIL}#" \ + /etc/bareos/bareos-dir.d/messages/Standard.conf + + # Setup webhook + if [ "${WEBHOOK_NOTIFICATION}" = true ]; then + sed -i "s#/usr/bin/bsmtp -h.*#/usr/local/bin/webhook-notify %t %e %c %l %n\"#" \ + /etc/bareos/bareos-dir.d/messages/Daemon.conf + sed -i "s#/usr/bin/bsmtp -h.*#/usr/local/bin/webhook-notify %t %e %c %l %n\"#" \ + /etc/bareos/bareos-dir.d/messages/Standard.conf + fi + + # storage daemon + sed -i 's#Address = .*#Address = '\""${BAREOS_SD_HOST}"\"'#' \ + /etc/bareos/bareos-dir.d/storage/File.conf + sed -i 's#Password = .*#Password = '\""${BAREOS_SD_PASSWORD}"\"'#' \ + /etc/bareos/bareos-dir.d/storage/File.conf + + # client/file daemon + sed -i 's#Address = .*#Address = '\""${BAREOS_FD_HOST}"\"'#' \ + /etc/bareos/bareos-dir.d/client/bareos-fd.conf + sed -i 's#Password = .*#Password = '\""${BAREOS_FD_PASSWORD}"\"'#' \ + /etc/bareos/bareos-dir.d/client/bareos-fd.conf + + # webUI + sed -i 's#Password = .*#Password = '\""${BAREOS_WEBUI_PASSWORD}"\"'#' \ + /etc/bareos/bareos-dir.d/console/admin.conf + sed -i "s#}# TlsEnable = false\n}#" \ + /etc/bareos/bareos-dir.d/console/admin.conf + + # MyCatalog Backup + sed -i "s#/var/lib/bareos/bareos.sql#/var/lib/bareos-director/bareos.sql#" \ + /etc/bareos/bareos-dir.d/fileset/Catalog.conf + + # Control file + touch /etc/bareos/bareos-config.control +fi + +if [[ -z ${CI_TEST} ]] ; then + # Waiting Postgresql is up + sqlup=1 + while [ "$sqlup" -ne 0 ] ; do + echo "Waiting for postgresql..." + pg_isready --host="${DB_HOST}" --port="${DB_PORT}" --user="${DB_ADMIN_USER}" + if [ $? -ne 0 ] ; then + sqlup=1 + sleep 5 + else + sqlup=0 + echo "...postgresql is alive" + fi + done +fi + +export PGUSER=${DB_ADMIN_USER} +export PGHOST=${DB_HOST} +export PGPASSWORD=${DB_ADMIN_PASSWORD} +[[ -z "${DB_INIT}" ]] && DB_INIT='false' +[[ -z "${DB_UPDATE}" ]] && DB_UPDATE='false' + +if [ ! -f /etc/bareos/bareos-db.control ] && [ "${DB_INIT}" == 'true' ] ; then + # Init Postgresql DB + echo "Bareos DB init" + echo "Bareos DB init: Create user ${DB_USER}" + psql -c "create user ${DB_USER} with createdb createrole login;" + echo "Bareos DB init: Set user password" + psql -c "alter user ${DB_USER} password '${DB_PASSWORD}';" + /usr/lib/bareos/scripts/create_bareos_database 2>/dev/null + /usr/lib/bareos/scripts/make_bareos_tables 2>/dev/null + /usr/lib/bareos/scripts/grant_bareos_privileges 2>/dev/null + + # Control file + touch /etc/bareos/bareos-db.control +fi + +if [ "${DB_UPDATE}" == 'true' ] ; then + # Try Postgres upgrade + echo "Bareoos DB update" + echo "Bareoos DB update: Update tables" + /usr/lib/bareos/scripts/update_bareos_tables 2>/dev/null + echo "Bareoos DB update: Grant privileges" + /usr/lib/bareos/scripts/grant_bareos_privileges 2>/dev/null +fi + +# Fix permissions +find /etc/bareos ! -user bareos -exec chown bareos {} \; +chown -R bareos:bareos /var/lib/bareos + +# Run Dockerfile CMD +exec "$@" diff --git a/director-pgsql/24-ubuntu/webhook-notify b/director-pgsql/24-ubuntu/webhook-notify new file mode 100644 index 00000000..801e3eaa --- /dev/null +++ b/director-pgsql/24-ubuntu/webhook-notify @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +job_type=$1 +job_status=$2 +job_client=$3 +job_level=$4 +job_name=$5 +msg_icon="❌" + +if [ "$job_status" = "OK" ] ;then + msg_icon="✅" +fi + +msg_txt="$msg_icon Bareos: $job_type $job_status of $job_client \ +$job_level (${job_name})" + +load_json() +{ + if [ "${WEBHOOK_TYPE}" = "slack" ] ; then + cat < /etc/apt/sources.list.d/bareos.list \ + && apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends \ + bareos-storage bareos-tools bareos-storage-tape mtx scsitools \ + sg3-utils mt-st bareos-storage-droplet \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod u+x /docker-entrypoint.sh + +RUN tar czf /bareos-sd.tgz /etc/bareos/bareos-sd.d + +EXPOSE 9103 + +VOLUME /etc/bareos +VOLUME /var/lib/bareos/storage + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/bareos-sd", "-u", "bareos", "-f"] diff --git a/storage/24-ubuntu/docker-entrypoint.sh b/storage/24-ubuntu/docker-entrypoint.sh new file mode 100644 index 00000000..a7134011 --- /dev/null +++ b/storage/24-ubuntu/docker-entrypoint.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +bareos_sd_config="/etc/bareos/bareos-sd.d/director/bareos-dir.conf" + +if [ ! -f /etc/bareos/bareos-config.control ]; then + tar xfz /bareos-sd.tgz --backup=simple --suffix=.before-control + + # Update bareos-storage configs + sed -i 's#Password = .*#Password = '\""${BAREOS_SD_PASSWORD}"\"'#' $bareos_sd_config + + # Control file + touch /etc/bareos/bareos-config.control +fi + +# Fix permissions +find /var/lib/bareos ! -user bareos -exec chown bareos {} \; +find /etc/bareos/bareos-sd.d ! -user bareos -exec chown bareos {} \; +find /dev -regex "/dev/[n]?st[0-9]+" ! -user bareos -exec chown bareos {} \; +find /dev -regex "/dev/tape/.*" ! -user bareos -exec chown bareos {} \; + +# Run Dockerfile CMD +exec "$@" diff --git a/webui/21-alpine/Dockerfile b/webui/21-alpine/Dockerfile index 89a67d6f..ea9b3d21 100644 --- a/webui/21-alpine/Dockerfile +++ b/webui/21-alpine/Dockerfile @@ -1,5 +1,5 @@ # Bareos Web-ui Dockerfile -FROM alpine:3.16 +FROM alpine:3.17 RUN apk add --no-cache bareos-webui-nginx diff --git a/webui/22-alpine/Dockerfile b/webui/22-alpine/Dockerfile index d11596da..08ad7177 100644 --- a/webui/22-alpine/Dockerfile +++ b/webui/22-alpine/Dockerfile @@ -1,5 +1,5 @@ # Bareos Web-ui Dockerfile -FROM alpine:3.20 +FROM alpine:3.18 RUN apk add --no-cache bareos-webui-nginx diff --git a/webui/24-ubuntu/Dockerfile b/webui/24-ubuntu/Dockerfile new file mode 100644 index 00000000..bcf32581 --- /dev/null +++ b/webui/24-ubuntu/Dockerfile @@ -0,0 +1,44 @@ +# Bareos Web-ui Dockerfile +FROM ubuntu:noble + +LABEL maintainer="barcus@tou.nu" + +ARG BUILD_DATE +ARG NAME +ARG VCS_REF +ARG VERSION + +LABEL org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$NAME \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/barcus/bareos" \ + org.label-schema.version=$VERSION + +ENV BAREOS_KEY=http://download.bareos.org/current/xUbuntu_24.04/Release.key +ENV BAREOS_REPO=http://download.bareos.org/current/xUbuntu_24.04/ +ENV DEBIAN_FRONTEND=noninteractive + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN apt-get update -qq \ + && apt-get -qq -y install --no-install-recommends curl tzdata gnupg \ + && curl -Ls $BAREOS_KEY | gpg --dearmor -o /usr/share/keyrings/bareos.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/bareos.gpg] $BAREOS_REPO /" > /etc/apt/sources.list.d/bareos.list \ + && apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends \ + bareos-webui \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod u+x /docker-entrypoint.sh + +RUN tar czf /bareos-webui.tgz /etc/bareos-webui + +EXPOSE 80 + +VOLUME /etc/bareos-webui + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] diff --git a/webui/24-ubuntu/docker-entrypoint.sh b/webui/24-ubuntu/docker-entrypoint.sh new file mode 100644 index 00000000..94b0af54 --- /dev/null +++ b/webui/24-ubuntu/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +if [ ! -f /etc/bareos-webui/bareos-config.control ];then + tar xzf /bareos-webui.tgz --backup=simple --suffix=.before-control + + # Update bareos-webui config + sed -i 's#diraddress.*#diraddress = '\""${BAREOS_DIR_HOST}"\"'#' \ + /etc/bareos-webui/directors.ini + + # Control file + touch /etc/bareos-webui/bareos-config.control +fi + +apache_conf="/etc/apache2/sites-available/000-default.conf" + +# Set document root +sed -i "s#/var/www/html#/usr/share/bareos-webui/public#g" $apache_conf + +# Enable Apache server stats +if [ "${SERVER_STATS}" == "yes" ]; then + sed -i 's!#ServerName.*!Alias /server-status /var/www/dummy!' $apache_conf +fi + +# Run Dockerfile CMD +exec "$@"