diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b013588 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,53 @@ +name: docker + +on: + push: + tags: + - "v*" + +jobs: + prepare-and-build: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + nite07/live-streamer + ghcr.io/nitezs/live-streamer + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + build-args: | + "version=${{ github.ref_name }}" + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..994a799 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.23 as builder +LABEL authors="nite07" + +WORKDIR /app +COPY . . +RUN go mod download +ARG version +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X live-streamer/constant.Version=${version}" -o live-streamer . + +FROM alpine:latest +COPY --from=builder /app/live-streamer /app/live-streamer +EXPOSE 8080 +VOLUME [ "/app/config.json" ] +CMD ["/app/live-streamer"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..90c7493 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +services: + live-streamer: + image: nite07/live-streamer + ports: + - 8080:8080 + volumes: + - ./config.json:/app/config.json + - ./videos:/videos