From a394df6210caa163c3f914d9aa2bdbc6e472a442 Mon Sep 17 00:00:00 2001 From: ngn Date: Tue, 28 Jan 2025 10:11:38 +0300 Subject: [PATCH] new: docker workflow Signed-off-by: ngn --- .gitea/workflows/docker.yml | 28 ++++++++++++++++++++++++++++ Dockerfile | 9 +++++++-- README.md | 17 ++++++++--------- 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 .gitea/workflows/docker.yml diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..cdd601d --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,28 @@ +name: Build docker image + +on: + push: + branches: ["main"] + +env: + REGISTRY: git.matterlinux.xyz + IMAGE: ${{gitea.repository}} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: "https://github.com/actions/checkout@v4" + + - name: Login to container repo + uses: "https://github.com/docker/login-action@v1" + with: + registry: ${{env.REGISTRY}} + username: ${{gitea.actor}} + password: ${{secrets.PACKAGES_TOKEN}} + + - name: Build image + run: | + docker build --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest . + docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest diff --git a/Dockerfile b/Dockerfile index 92fbc7c..f51a1af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM libmp as build +FROM git.matterlinux.xyz/matter/libmp as build RUN apt update RUN apt install -y make gcc gettext libinih-dev libsqlite3-dev libarchive-dev @@ -13,7 +13,7 @@ COPY ./src ./src RUN make RUN make install -FROM libmp as main +FROM git.matterlinux.xyz/matter/libmp as main RUN apt update RUN apt install -y dumb-init @@ -26,4 +26,9 @@ COPY --from=build /usr/share/locale/tr/LC_MESSAGES/pooler.mo /usr/share/locale/t COPY --from=build /etc/pooler/config.ini /etc/pooler/config.ini COPY --from=build /usr/bin/pooler /usr/bin/pooler +RUN useradd runner -r -u 1001 +RUN chown -R runner:runner /var/lib/pooler +RUN chown -R runner:runner /etc/pooler +USER runner + ENTRYPOINT ["dumb-init", "/usr/bin/pooler", "/etc/pooler/config.ini"] diff --git a/README.md b/README.md index ad06e61..715e571 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # pooler | MatterLinux pool server + +![](https://git.matterlinux.xyz/matter/pooler/actions/workflows/docker.yml/badge.svg) + Simple MPTP server implementation for serving MatterLinux package pools. Built on top of [`libmp`](https://git.matterlinux.xyz/Matter/libmp). @@ -18,8 +21,7 @@ After installing these dependencies, you should download the latest release. If you are building this program for development purposes, then you may also build from the latest commit. However latest commit may not always be compilable. -After obtaining the source code, you can compile the program using the make -tool: +After obtaining the source code, you can compile the program using the make tool: ```bash make ``` @@ -36,17 +38,14 @@ docker build --tag pooler . And for deployment you can use docker-compose, here is an example configuration: ```yaml -version: "3" - services: pooler: - image: pooler - build: - context: ./ + container_name: pooler + image: git.matterlinux.xyz/matter/pooler ports: - - "5858:5858/tcp" + - "5858:5858/tcp" volumes: - - "./config.ini:/etc/pooler/config.ini" + - "./config.ini:/etc/pooler/config.ini" ``` Just make sure you read the compose file and place the configuration file and the pools to the right place: