From ce78bf803b3fe11442b46000ff01e3765fe28c44 Mon Sep 17 00:00:00 2001 From: ngn Date: Tue, 28 Jan 2025 07:38:24 +0300 Subject: [PATCH 1/4] new: docker workflow action Signed-off-by: ngn --- .gitea/workflows/docker.yml | 28 ++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++---- 2 files changed, 38 insertions(+), 4 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..f21c93a --- /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}}/doc + +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 c156d53..f333252 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,22 @@ FROM golang:1.23.2 WORKDIR /app -COPY *.go ./ -COPY *.mod ./ -COPY *.sum ./ +RUN useradd runner -r -u 1001 -d /app +RUN chown -R runner:runner /app +USER runner +COPY *.mod ./ +COPY *.sum ./ + +RUN go mod download + +COPY *.go ./ COPY lib ./lib COPY log ./log COPY public ./public COPY routes ./routes COPY templates ./templates -RUN go build . +RUN make ENTRYPOINT ["/app/tracker"] From 094aa2a96d46c2fa210ddea98f3888c24089dd75 Mon Sep 17 00:00:00 2001 From: ngn Date: Tue, 28 Jan 2025 07:56:11 +0300 Subject: [PATCH 2/4] fix: copy makefile in dockerfile Signed-off-by: ngn --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index f333252..dc4bf9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ COPY *.sum ./ RUN go mod download COPY *.go ./ +COPY Makefile ./ COPY lib ./lib COPY log ./log COPY public ./public From 7555bb3f673310228bba645446d5992899ef6992 Mon Sep 17 00:00:00 2001 From: ngn Date: Tue, 28 Jan 2025 07:59:04 +0300 Subject: [PATCH 3/4] update: readme deployment instructions Signed-off-by: ngn --- README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0b612d2..1ae0e8c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # tracker | MatterLinux package tracker + +![](https://git.matterlinux.xyz/matter/tracker/actions/workflows/docker.yml/badge.svg) + Soruce code of MatterLinux's package tracker, located at [tracker.matterlinux.xyz](https://tracker.matterlinux.xyz) @@ -39,23 +42,19 @@ official MatterLinux 24 repos: ``` ### Deployment -Web server can be built and deployed with docker compose using the following -configuration file: +Web server can be deployed with docker compose using the following configuration file: ```yaml -version: "3" - services: tracker: - image: mattertracker - restart: unless-stopped - build: - context: ./ + container_name: mattertracker + image: git.matterlinux.xyz/matter/tracker ports: - - "127.0.0.1:9877:9877" + - "127.0.0.1:9877:9877" volumes: - - "./config.json:/app/config.json:ro" + - "./config.json:/app/config.json:ro" + restart: unless-stopped ``` -After saving the configuration file, you can build and run the docker container: +After saving the configuration file, you can run the docker container: ```bash docker-compose up -d ``` From a593dff15bab47e7d0ef666804d7ccb2a5f4bae1 Mon Sep 17 00:00:00 2001 From: ngn Date: Tue, 28 Jan 2025 08:02:38 +0300 Subject: [PATCH 4/4] fix: action container name Signed-off-by: ngn --- .gitea/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index f21c93a..cdd601d 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -6,7 +6,7 @@ on: env: REGISTRY: git.matterlinux.xyz - IMAGE: ${{gitea.repository}}/doc + IMAGE: ${{gitea.repository}} jobs: build: