Skip to content

Commit fd190e3

Browse files
committed
initial commit
0 parents  commit fd190e3

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

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

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ghcr.io/uceap/devcontainer-db:v1.0.0 AS importer
2+
3+
# drupal devcontainers should set these to match
4+
ENV MYSQL_ROOT_PASSWORD="PASSWORD"
5+
ENV MYSQL_DATABASE="drupal"
6+
ENV MYSQL_USER="drupal"
7+
ENV MYSQL_PASSWORD="PASSWORD"
8+
9+
# these are just for building
10+
ENV TERMINUS_SITE="SITENAME"
11+
ENV TERMINUS_ENV="dev"
12+
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
15+
# Download the database dump
16+
RUN --mount=type=secret,id=TERMINUS_TOKEN,env=TERMINUS_TOKEN \
17+
terminus auth:login --machine-token=$TERMINUS_TOKEN \
18+
&& terminus backup:get --element=db --to=/docker-entrypoint-initdb.d/database.sql.gz
19+
20+
# Some of the following is inspired by https://github.com/ispyb/ispyb-docker-pydb
21+
22+
# Entrypoint script does the DB initialization but also runs mysql daemon, but we only want it to initialize the DB
23+
RUN ["sed", "-i", "s/exec \"$@\"/echo \"not running $@\"/", "/usr/local/bin/docker-entrypoint.sh"]
24+
25+
# Need to change the datadir to something else that /var/lib/mysql because the parent docker file defines it as a volume.
26+
# https://docs.docker.com/engine/reference/builder/#volume :
27+
# Changing the volume from within the Dockerfile: If any build steps change the data within the volume after
28+
# it has been declared, those changes will be discarded.
29+
# Also run an empty
30+
RUN ["/usr/local/bin/docker-entrypoint.sh", "mariadbd", "--datadir", "/initialized-db", "--aria-log-dir-path", "/initialized-db"]
31+
32+
RUN rm /docker-entrypoint-initdb.d/*
33+
34+
FROM ghcr.io/uceap/devcontainer-db:v1.0.0
35+
36+
COPY --from=importer /initialized-db /var/lib/mysql

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
A MariaDB docker image with specific UCEAP Drupal development seed data baked-in.
2+
3+
This needs the TERMINUS_TOKEN secret to be set in order to download the database backup from Pantheon.
4+
5+
When working locally you can set the TERMINUS_TOKEN environment variable and pass it to the build process as a secret like so:
6+
7+
``` sh
8+
docker build -t myusername/devcontainer-db-generic --secret id=TERMINUS_TOKEN .
9+
```

0 commit comments

Comments
 (0)