diff --git a/.github/workflows/build-services.yaml b/.github/workflows/build-services.yaml index 5069344..9d3963b 100644 --- a/.github/workflows/build-services.yaml +++ b/.github/workflows/build-services.yaml @@ -39,5 +39,5 @@ jobs: service: openev-data-mcp-service push: ${{ github.event_name != 'pull_request' }} repository: openev-data-mcp-service - dockerfile: "./build/service/Dockerfile" + dockerfile: "./build/Dockerfile" secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..bfb9809 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,52 @@ +name: Release + +on: + push: + tags: + - 'v*' # Trigger on version tags like v1.0.0 + workflow_dispatch: + +jobs: + release: + name: Run GoReleaser + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + # Checkout the code + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Set up Go environment + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.24 + + # Set up Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Login to GitHub Container Registry + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Run GoReleaser + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} + GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }} + diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..2f0c54c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,53 @@ +# GoReleaser configuration file +version: 2 + +# General settings +project_name: openev-data-mcp +builds: + - id: bin + main: ./cmd/app + binary: openev-data-mcp + goos: + - freebsd + - windows + - darwin + - linux + goarch: + - amd64 + - arm64 + - arm + ignore: + - goos: windows + goarch: arm + - goos: freebsd + goarch: arm + +archives: + - id: bin-archive + formats: + - tar.gz + files: + - LICENSE.md + - README.md + +dockers_v2: + - images: + - "ghcr.io/chargepi/openev-data-mcp" + tags: + - "{{ .Tag }}" + - "latest" + dockerfile: Dockerfile.release + platforms: + - linux/amd64 + - linux/arm64 + +release: + github: + owner: "{{ .Env.GITHUB_REPOSITORY_OWNER }}" + name: openev-data-mcp + +changelog: + sort: asc + filters: + exclude: + - '.*\.md$' \ No newline at end of file diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 0000000..aaafad8 --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,12 @@ +FROM alpine:3.21 + +ARG TARGETPLATFORM +ARG user=app +ARG group=docker +RUN addgroup $group && adduser -D -G $group $user +USER $user + +WORKDIR /usr/local/bin +COPY --chown=$user:$group $TARGETPLATFORM/openev-data-mcp /usr/local/bin/openev-data-mcp + +CMD ["/usr/local/bin/openev-data-mcp"] \ No newline at end of file diff --git a/build/service/Dockerfile b/build/Dockerfile similarity index 79% rename from build/service/Dockerfile rename to build/Dockerfile index 381701e..fb3e431 100644 --- a/build/service/Dockerfile +++ b/build/Dockerfile @@ -13,7 +13,7 @@ RUN go mod verify COPY . . -RUN --mount=type=cache,target="/root/.cache/go-build" go build -o ../service ./cmd/app +RUN --mount=type=cache,target="/root/.cache/go-build" go build -o ../openev-data-mcp ./cmd/app # Debug stage using Delve FROM build AS debug @@ -22,9 +22,9 @@ COPY --from=build /app/src /service/src WORKDIR /service/src RUN go install github.com/go-delve/delve/cmd/dlv@latest -RUN go build -gcflags="all=-N -l" -o ./service ./cmd/app +RUN go build -gcflags="all=-N -l" -o ./openev-data-mcp ./cmd/app -CMD ["/go/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./service"] +CMD ["/go/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./openev-data-mcp"] # Fetch grpc_health_probe for the final image health check FROM alpine:3.21 AS health-probe @@ -44,13 +44,13 @@ RUN addgroup $group && \ --ingroup $group \ $user -COPY --chown=$user:$group --from=build /app/service /usr/local/bin/service +COPY --chown=$user:$group --from=build /app/openev-data-mcp /usr/local/bin/openev-data-mcp COPY --from=health-probe /grpc_health_probe /usr/local/bin/grpc_health_probe USER $user -WORKDIR /usr/local/service +WORKDIR /usr/local/openev-data-mcp HEALTHCHECK --interval=10s --timeout=3s --retries=3 \ CMD ["/usr/local/bin/grpc_health_probe", "-addr=:9090"] -CMD ["/usr/local/bin/service"] \ No newline at end of file +CMD ["/usr/local/bin/openev-data-mcp"] \ No newline at end of file diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml index f5a575b..dcfbaab 100644 --- a/deployments/docker/docker-compose.yaml +++ b/deployments/docker/docker-compose.yaml @@ -20,7 +20,7 @@ services: app: build: context: ../.. - dockerfile: build/service/Dockerfile + dockerfile: ../../build/Dockerfile restart: unless-stopped environment: OPENEV_MCP_DATABASE_HOST: db