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 c156d53..dc4bf9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,23 @@ 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 Makefile ./ COPY lib ./lib COPY log ./log COPY public ./public COPY routes ./routes COPY templates ./templates -RUN go build . +RUN make ENTRYPOINT ["/app/tracker"] 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 ```