Skip to content

Commit

Permalink
docker versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatik committed Jul 13, 2021
1 parent 0b59164 commit 1321529
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
name: Docker CI-CD

# Controls when the action will run.
# on:
# # Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [ main ]
# paths:
# - '**.js'
# pull_request:
# branches: [ main ]
# paths:
# - '**.js'

on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- '**.js'
pull_request:
branches: [ main ]
paths:
- '**.js'
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down Expand Up @@ -51,13 +56,27 @@ jobs:
with:
username: ${{ secrets.Docker_username }}
password: ${{ secrets.Docker_password }}

- name: Get current date
id: getDate
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- name: Get semantic version from file
id: getSemver
run: echo "::set-output name=semver::$(cat VERSION | tr -d ' \t\n\r' )"

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: dmatik/oref-alerts:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
dmatik/oref-alerts:latest
dmatik/oref-alerts:${{ steps.getSemver.outputs.semver }}
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ steps.getDate.outputs.date }}
VERSION=${{ steps.getSemver.outputs.semver }}
20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,22 @@ RUN npm ci --only=production
COPY . .

EXPOSE 3000
CMD [ "node", "server.js" ]
CMD [ "node", "server.js" ]


ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

LABEL org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.authors="Dmitry Trosman <mailto:[email protected]>" \
org.opencontainers.image.url="https://hub.docker.com/r/dmatik/oref-alerts" \
org.opencontainers.image.documentation="https://dmatik.github.io/docs/oref_alerts" \
org.opencontainers.image.source="https://github.com/dmatik/orefAlerts" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.vendor="https://www.oref.org.il/" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.ref.name=$VERSION \
org.opencontainers.image.title="dmatik/oref-alerts" \
org.opencontainers.image.description="Node.js RESTful API to retrieve Israeli Pikud Ha-Oref so called Red Color alerts"
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.2

0 comments on commit 1321529

Please sign in to comment.