diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml new file mode 100644 index 0000000..47edd3f --- /dev/null +++ b/.github/workflows/developer.yml @@ -0,0 +1,48 @@ +--- +name: Developer image +on: # yamllint disable-line rule:truthy + push: + branches: [main] + +jobs: + push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker - Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker - GHCR Login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker - Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} + tags: type=raw,value=dev + flavor: latest=false + + - name: Docker - Build / Push + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c5f9eff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +--- +name: Release +on: # yamllint disable-line rule:truthy + release: + types: [published] + +jobs: + # Builds the Dockerfile and pushes it to dockerhub and GHCR + release: + name: Release - Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker - Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker - GHCR Login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker - Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + flavor: latest=true + + - name: Docker - Build / Push + id: docker_build + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index fa3a9e7..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,11 +0,0 @@ -build-docker: - stage: build - tags: - - docker - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fa1cf0b..daa1855 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,31 @@ -# Use the official Go image as the base image -FROM golang:1.21.5-alpine +# Start from the official Golang image +FROM golang:alpine AS build -# Set the working directory inside the container +# Set the Current Working Directory inside the container WORKDIR /app -# Copy the local package files to the container's workspace -COPY . . +# Copy go mod and sum files +COPY go.mod go.sum ./ -# Download and install any dependencies +# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed RUN go mod download -# Build the Go application +# Copy the source code from the current directory to the Working Directory inside the container +COPY . . + +# Build the Go app RUN go build -o main . +#################### + +FROM scratch + +WORKDIR / + +COPY --from=build /app/main /gomain + EXPOSE 8080 -# Command to run the executable -ENTRYPOINT ["./main"] \ No newline at end of file +ENTRYPOINT ["/gomain"] + + diff --git a/README.md b/README.md index 6caeddd..6a23ed9 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ version: '3' services: m3u-stream-merger-proxy: - image: registry.snry.xyz/sysadmin/m3u-stream-merger:main-latest + image: sonroyaalmerol/m3u-stream-merger:latest ports: - "8080:8080" volumes: