Skip to content

Commit

Permalink
Merge pull request #87 from orange-cloudfoundry/dockerfile
Browse files Browse the repository at this point in the history
Added dockerfile (test)
  • Loading branch information
romain-dartigues authored May 14, 2024
2 parents a913737 + c25d42a commit 7772729
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: build-and-release

on:
push:
branches:
- '!*'
tags:
- 'v[0-9].*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Compute docker tags
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v5
with:
images: orangeopensource/credhub-exporter

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to DockerHub
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.docker_meta.outputs.tags }}

- name: Create github release
id: create-github-release
if: success() && startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
Resource image available:
```
${{ steps.docker_meta.outputs.tags }}
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stage 1
FROM golang:1.22 as builder
WORKDIR /go/src/app
COPY . .
RUN go mod tidy
RUN go mod vendor
RUN CGO_ENABLED=0 go build -o /go/bin/app/credhub_exporter -a -tags netgo -ldflags '-w -extldflags "-static"'

# Stage 2
FROM alpine:3.19
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/bin/app/credhub_exporter /bin/credhub_exporter
EXPOSE 9358
ENTRYPOINT ["/bin/credhub_exporter"]

0 comments on commit 7772729

Please sign in to comment.