Skip to content

Commit 0de707c

Browse files
authored
Merge pull request #2212 from glimchb/docker
feat(docker): add dockerfile and ci workflow for control plane
2 parents ab6801c + ed6fb05 commit 0de707c

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
# Publish semver tags as releases.
12+
tags: [ 'v*.*.*' ]
13+
pull_request:
14+
branches:
15+
- main
16+
- devel
17+
- release-1.4
18+
- release-1.4.0.1
19+
- release-1.4.1
20+
- release-1.4.2
21+
- devel-1.4.2
22+
- devel-1.4.2.1
23+
- devel-1.4.2.2
24+
- devel-1.5
25+
- devel-1.6
26+
27+
env:
28+
# Use docker.io for Docker Hub if empty
29+
REGISTRY: ghcr.io
30+
# github.repository as <account>/<repo>
31+
IMAGE_NAME: ${{ github.repository }}
32+
33+
34+
jobs:
35+
build:
36+
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: read
40+
packages: write
41+
# This is used to complete the identity challenge
42+
# with sigstore/fulcio when running outside of PRs.
43+
id-token: write
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v3
48+
49+
# Install the cosign tool except on PR
50+
# https://github.com/sigstore/cosign-installer
51+
- name: Install cosign
52+
if: github.event_name != 'pull_request'
53+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
54+
with:
55+
cosign-release: 'v2.1.1'
56+
57+
# Set up BuildKit Docker container builder to be able to build
58+
# multi-platform images and export cache
59+
# https://github.com/docker/setup-buildx-action
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
62+
63+
# Login against a Docker registry except on PR
64+
# https://github.com/docker/login-action
65+
- name: Log into registry ${{ env.REGISTRY }}
66+
if: github.event_name != 'pull_request'
67+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
68+
with:
69+
registry: ${{ env.REGISTRY }}
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
# Extract metadata (tags, labels) for Docker
74+
# https://github.com/docker/metadata-action
75+
- name: Extract Docker metadata
76+
id: meta
77+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
78+
with:
79+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
80+
81+
# Build and push Docker image with Buildx (don't push on PR)
82+
# https://github.com/docker/build-push-action
83+
- name: Build and push Docker image
84+
id: build-and-push
85+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
86+
with:
87+
context: .
88+
push: ${{ github.event_name != 'pull_request' }}
89+
tags: ${{ steps.meta.outputs.tags }}
90+
labels: ${{ steps.meta.outputs.labels }}
91+
cache-from: type=gha
92+
cache-to: type=gha,mode=max
93+
94+
# Sign the resulting Docker image digest except on PRs.
95+
# This will only write to the public Rekor transparency log when the Docker
96+
# repository is public to avoid leaking data. If you would like to publish
97+
# transparency data even for private images, pass --force to cosign below.
98+
# https://github.com/sigstore/cosign
99+
- name: Sign the published Docker image
100+
if: ${{ github.event_name != 'pull_request' }}
101+
env:
102+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
103+
TAGS: ${{ steps.meta.outputs.tags }}
104+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
105+
# This step uses the identity token to provision an ephemeral certificate
106+
# against the sigstore community Fulcio instance.
107+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM rockylinux:8.8
2+
3+
WORKDIR /app
4+
5+
# why this is not part of prereq.sh ?
6+
RUN dnf install -y python38 iproute
7+
8+
# prereq
9+
RUN echo "SELINUX=disabled" > /etc/selinux/config
10+
COPY prereq.sh .
11+
RUN bash -euxo pipefail ./prereq.sh
12+
13+
# why this is not part of prereq.sh ?
14+
# see provision/roles/provision_validation/tasks/package_installation.yml
15+
RUN dnf install -y \
16+
python3-netaddr \
17+
openssl \
18+
dos2unix \
19+
net-snmp \
20+
net-snmp-utils \
21+
sshpass \
22+
python3-pexpect
23+
24+
# why above RPMs are not enough ?
25+
RUN python3 -m pip install netaddr pexpect
26+
27+
# why this is not part of prereq.sh ?
28+
# see telemetry/roles/omnia_telemetry_cp/tasks/python_package_installation.yml
29+
RUN python3 -m pip install pyinstaller psutil
30+
31+
ENTRYPOINT ["ansible-playbook"]
32+
CMD ["prepare_cp.yml", "-vv"]

prereq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ echo "-------------------"
3434
python3.8 -m pip install ansible==5.10.0
3535
python3.8 -m pip install jinja2==3.1.2
3636
dnf install git-lfs -y
37-
git lfs pull
37+
git lfs pull || true
3838

3939
selinux_count="$(grep "^SELINUX=disabled" /etc/selinux/config | wc -l)"
4040
if [[ $selinux_count == 0 ]];

0 commit comments

Comments
 (0)