Skip to content

Commit bca4ad9

Browse files
committed
Add docker image deployment support
Signed-off-by: Alireza Poodineh <[email protected]>
1 parent 48e83ac commit bca4ad9

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/docker.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
name: Create and publish EasyDev
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches: [master]
8+
9+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: sapteamdev/easydev
13+
14+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
#
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
42+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
43+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
44+
- name: Build and push Docker image
45+
id: push
46+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
47+
with:
48+
context: .
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
53+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
54+
- name: Generate artifact attestation
55+
uses: actions/attest-build-provenance@v2
56+
with:
57+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
58+
subject-digest: ${{ steps.push.outputs.digest }}
59+
push-to-registry: true
60+

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Use the official devcontainer .NET 8 image
22
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:9.0
33

4+
LABEL org.opencontainers.image.source=https://github.com/SAPTeamDEV/EasySign
5+
LABEL org.opencontainers.image.description=".NET Development Container"
6+
LABEL org.opencontainers.image.licenses=MIT
7+
8+
49
# Install additional apt packages
510
RUN apt-get update && apt-get install -y \
611
git \

0 commit comments

Comments
 (0)