Skip to content

Commit

Permalink
Add GHA for dockerhub builds (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
pudelkoM committed Mar 1, 2022
1 parent 384e569 commit 1241eeb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,58 @@ jobs:
run: |
make docker-build
make docker-push
push-dockerhub:
env:
DOCKER_REGISTRY: "docker.io/"
DOCKER_REPOSITORY: "omecproject/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0

- run: echo GIT_SHA_SHORT=$(git rev-parse --short HEAD) >> $GITHUB_ENV

- id: docker-login
# Secrets from the main repo are not used if PR comes from fork. We skip pushing Docker image then.
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
uses: docker/login-action@v1.13.0
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push "master-latest" Docker images for Haswell CPU
env:
DOCKER_TAG: master-latest
CPU: haswell
run: |
docker pull ${DOCKER_REPOSITORY}upf-epc-bess:$DOCKER_TAG
docker pull ${DOCKER_REPOSITORY}upf-epc-pfcpiface:$DOCKER_TAG
CPU=$CPU make docker-build
make docker-push
- name: Build and push "master-GIT_SHA" Docker images for Haswell CPU
env:
DOCKER_TAG: master-latest-${{ env.GIT_SHA_SHORT }}
CPU: haswell
run: |
CPU=$CPU make docker-build
make docker-push
- name: Build and push "master-latest-ivybridge" Docker images for Ivybridge CPU
env:
DOCKER_TAG: master-latest-ivybridge
CPU: ivybridge
run: |
docker pull ${DOCKER_REPOSITORY}upf-epc-bess:$DOCKER_TAG
docker pull ${DOCKER_REPOSITORY}upf-epc-pfcpiface:$DOCKER_TAG
CPU=$CPU make docker-build
make docker-push
- name: Build and push "master-GIT_SHA-ivybridge" Docker images for Ivybridge CPU
env:
DOCKER_TAG: master-latest-ivybridge-${{ env.GIT_SHA_SHORT }}
CPU: ivybridge
run: |
CPU=$CPU make docker-build
make docker-push
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ PTF_PB_DIR ?= ptf/lib
# https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target
docker-build:
for target in $(DOCKER_TARGETS); do \
DOCKER_CACHE_ARG=""; \
if [ $(DOCKER_BUILDKIT) = 1 ]; then \
DOCKER_CACHE_ARG="--cache-from ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}upf-epc-$$target:${DOCKER_TAG}"; \
fi; \
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build $(DOCKER_PULL) $(DOCKER_BUILD_ARGS) \
--target $$target \
$$DOCKER_CACHE_ARG \
--tag ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}upf-epc-$$target:${DOCKER_TAG} \
--label org.opencontainers.image.source="https://github.com/omec-project/upf-epc" \
--label org.label.schema.version="${VERSION}" \
Expand Down

0 comments on commit 1241eeb

Please sign in to comment.