Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
ci: Add docker build, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Jan 27, 2022
1 parent ce605ab commit 9090b25
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 77 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: release
on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: riotkit-org/backup-controller

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and release
uses: docker/build-push-action@v2
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 6 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ jobs:
- name: Test
run: |
make tests
- name: Build container
uses: docker/build-push-action@v2
with:
context: .
push: false
52 changes: 0 additions & 52 deletions .rkd/makefile.py

This file was deleted.

43 changes: 22 additions & 21 deletions .rkd/docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
FROM python:3.9-alpine3.13
FROM python:3.9-alpine3.14
MAINTAINER RiotKit <riotkit.org>

ARG JOBBER_VERSION="1.4.4"
ARG JOBBER_BUILD_SUFFIX="-r0"
ARG USER=bahub
ARG USER=backup-controller
ARG UID=1000
ARG GID=1000
ENV CONFIG="bahub.conf.yaml"
ENV CONFIG="backup-controller.conf.yaml"
ENV DEBUG="false"

# Create a non-privileged user
RUN addgroup --gid $GID bahub \
RUN addgroup --gid $GID $USER \
&& adduser \
--disabled-password \
--gecos "" \
--home "/home/bahub" \
--home "/home/$USER" \
--ingroup "$USER" \
--uid "$UID" \
"$USER"
Expand All @@ -25,7 +25,8 @@ WORKDIR /tmp
RUN apk update && apk add --no-cache bash
SHELL ["/bin/bash", "-c"]

# install docker client, and shell utilities as dependencies required by built-in Bahub adapters
# install docker client, and shell utilities as dependencies required by built-in Backup Maker adapters
# in case, when using "sh" transport to execute backup inside same container
RUN apk add --no-cache libcurl docker git postgresql-client mysql-client tar sudo gnupg curl

# install jobber (a cron-like alternative)
Expand All @@ -34,31 +35,31 @@ RUN cd / && wget https://github.com/dshearer/jobber/releases/download/v$JOBBER_V
&& ln -s /usr/libexec/jobber* /usr/bin/ \
&& rm jobber-*.apk

# install Bahub system wide inside container. GIT is required for version information for Python's PBR
ADD bahub /bahub
ADD .git /bahub/.git
WORKDIR /bahub
# install as system wide inside container. GIT is required for version information for Python's PBR
ADD ./ /backup-controller
ADD .git /backup-controller/.git
WORKDIR /backup-controller
USER root
RUN set -x; apk add --virtual .build-deps gcc musl-dev python3-dev curl-dev libffi-dev \
&& pip install -r ./requirements.txt \
&& ./setup.py build sdist \
&& ./setup.py install \
&& apk del .build-deps \
&& rm -rf /bahub
&& rm -rf /backup-controller

# Now we will operate only on /home/bahub directory
ADD bahub/bahub.conf.yaml /home/bahub/bahub.conf.yaml
ADD bahub/.rkd/docker/.jobber /home/bahub/.jobber
RUN mkdir -p /home/bahub/logs /var/jobber/0 && touch /home/bahub/logs/jobber.log
RUN chown root:root -R /home/bahub /var/jobber/0
# Now we will operate only on /home/backup-controller directory
ADD backup-controller.conf.yaml /home/$USER/backup-controller.conf.yaml
ADD docker-files/.jobber /home/$USER/.jobber
RUN mkdir -p /home/$USER/logs /var/jobber/0 && touch /home/$USER/logs/jobber.log
RUN chown root:root -R /home/$USER /var/jobber/0

ADD bahub/.rkd/docker/entrypoint.sh /entrypoint.sh
ADD docker-files/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

WORKDIR /home/bahub
WORKDIR /home/$USER

# We need root permissions to preserve file permissions, especially on restore
USER root
# backup-controller is just a scheduler, it should not need root privileges
USER $USER

ENTRYPOINT ["/entrypoint.sh"]
CMD ["--unixsocket", "/var/jobber/0/cmd.sock", "/home/bahub/.jobber"]
CMD ["--unixsocket", "/home/$USER/cmd.sock", "/home/$USER/.jobber"]
4 changes: 2 additions & 2 deletions bahub.conf.yaml → backup-controller.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ accesses:

encryption:
strong:
private_key_path: "../backup-maker/resources/test/gpg-key.asc"
private_key_path: "~/Projekty/riotkit/br-backup-maker/resources/test/gpg-key.asc"
public_key_path: ""
passphrase: "riotkit"
email: "[email protected]"
Expand All @@ -36,7 +36,7 @@ transports:
container: "nginx_bahub_test"

side_docker_fs:
type: bahub.transports.sidedocker
type: bahub.transports.docker_sidecontainer
spec:
orig_container: "nginx_bahub_test"
temp_container_image: "alpine:3.12"
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ classifier =
packages = bahub
packages_root = ./
data_files =
local/etc/bahub/ = ./bahub.conf.yaml
local/etc/bahub/ = ./backup-controller.conf.yaml

[entry_points]
console_scripts =
bahub = bahub:main
backup-controller = bahub:main

0 comments on commit 9090b25

Please sign in to comment.