Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

docker container ghcr.io build script #10

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build Docker Image
on:
pull_request:
branches: [ main]
push:
branches: [ main]

# https://docs.github.com/en/actions/quickstart
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
jobs:
build:
runs-on: ubuntu-latest
steps:
# need to create an environment variable with org + repo in lowercase not HabitatEnergy
- name: downcase REPO
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: 1.*
check-latest: true

# 🤓 https://github.com/actions/checkout
- name: Checkout
uses: actions/[email protected]
with:
# fetch-depth: 0
path: ''

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: false
tags: latest
#tags: $REPO:$(date +%s), $REPO:latest

#-
# name: Build the Docker image
# run: docker build . --file Dockerfile --tag ${REPO}:$(date +%s)

#- uses: actions/checkout@v2
# name: Check out code

#- uses: mr-smithers-excellent/docker-build-push@v5
# name: Build & push Docker image
# with:
# image: $REPO
# tags: v1, latest
# registry: registry-url.io
# dockerfile: Dockerfile.ci
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

#-
# name: Build and publish image
# uses: zmingxie/docker_buildx@master
# with:
# publish: false
# platform: linux/amd64
# imageName: ${REPO}

# 🤓 https://github.com/marketplace/actions/ghcr-docker-buildx-build
#- name: GHCR Docker Buildx Build
# uses: bskiefer/[email protected]

# 🤓 https://github.com/marketplace/actions/ghcr-action
#- name: GHCR-Action
# uses: KuhlTime/ghcr-action@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}

#- name: Build Docker Image0
# run: |
# docker build -t .
#- name: Push Docker Image
# run: |
# echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
# docker push ghcr.io/$REPO:$GITHUB_RUN_ID
# https://github.com/marketplace/actions/push-to-ghcr

- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@master
with:
image_name: ${{ github.repository }} # it will be lowercased internally
github_token: ${{ secrets.GITHUB_TOKEN }}
# optionally push to the Docker Hub (docker.io)
# docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} # see https://hub.docker.com/settings/security
# customize the username to be used when pushing to the Docker Hub
# docker_io_user: foobar # see https://github.com/macbre/push-to-ghcr/issues/14

11 changes: 6 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
fail-fast: false
matrix:
go-version:
- 1.14.x
- 1.15.x
- 1.16.x
- 1.17.x
- 1.x
# - 1.14.x
# - 1.15.x
# - 1.16.x
# - 1.17.x
# - 1.x
- 1.18.x
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:latest

RUN mkdir /app
COPY . /app

WORKDIR /app
RUN make

EXPOSE 9903

CMD ["./ipsec_exporter"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ make
./ipsec_exporter [flags]
```

## Docker Container
```
docker pull ghcr.io/habitatenergy/ipsec_exporter
```

## Exported metrics

### Exported for both strongswan/libreswan
Expand Down