-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker image creation for crossreference
- Loading branch information
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
name: bbm-build-crossreference | ||
|
||
on: | ||
push: | ||
paths: | ||
- "cross-reference/**" | ||
- .github/workflows/bbm_build_crossreference.yml | ||
pull_request: | ||
paths: | ||
- "cross-reference/**" | ||
- .github/workflows/bbm_build_crossreference.yml | ||
|
||
defaults: | ||
run: | ||
working-directory: cross-reference | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: build | ||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check Dockerfile with hadolint | ||
run: | | ||
docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile | ||
- name: Set up env vars | ||
run: | | ||
echo "REPO=bb-master" >>$GITHUB_ENV | ||
- name: Build cross-reference | ||
run: | | ||
podman build . --tag ${{ env.REPO }}:crossreference | ||
- name: Push images to local registry | ||
run: | | ||
for img in crossreference; do | ||
podman push --tls-verify=0 \ | ||
${{ env.REPO }}:$img \ | ||
docker://localhost:5000/${{ env.REPO }}:$img | ||
done | ||
- name: Check for registry credentials | ||
if: > | ||
github.ref == 'refs/heads/main' && | ||
github.repository == 'MariaDB/buildbot' | ||
run: | | ||
missing=() | ||
[[ -n "${{ secrets.QUAY_USER }}" ]] || missing+=(QUAY_USER) | ||
[[ -n "${{ secrets.QUAY_TOKEN }}" ]] || missing+=(QUAY_TOKEN) | ||
for i in "${missing[@]}"; do | ||
echo "Missing github secret: $i" | ||
done | ||
if (( ${#missing[@]} == 0 )); then | ||
echo "DEPLOY_IMAGES=true" >> $GITHUB_ENV | ||
else | ||
echo "Not pushing images to registry" | ||
fi | ||
- name: Login to ghcr.io | ||
if: ${{ env.DEPLOY_IMAGES == 'true' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push images to ghcr.io | ||
if: ${{ env.DEPLOY_IMAGES == 'true' }} | ||
run: | | ||
msg="Push docker images to ghcr.io" | ||
line="${msg//?/=}" | ||
printf "\n${line}\n${msg}\n${line}\n" | ||
for image in crossreference; do | ||
skopeo copy --all --src-tls-verify=0 \ | ||
docker://localhost:5000/${{ env.REPO }}:${image} \ | ||
docker://ghcr.io/mariadb/buildbot:${image} | ||
done | ||
- name: Login to quay.io | ||
if: ${{ env.DEPLOY_IMAGES == 'true' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USER }} | ||
password: ${{ secrets.QUAY_TOKEN }} | ||
- name: Push images to quay.io | ||
if: ${{ env.DEPLOY_IMAGES == 'true' }} | ||
run: | | ||
msg="Push docker images to quay.io" | ||
line="${msg//?/=}" | ||
printf "\n${line}\n${msg}\n${line}\n" | ||
for image in crossreference; do | ||
skopeo copy --all --src-tls-verify=0 \ | ||
docker://localhost:5000/${{ env.REPO }}:${image} \ | ||
docker://quay.io/mariadb-foundation/${{ env.REPO }}:${image} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.11-slim-alpine | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Set work directory | ||
WORKDIR /app | ||
|
||
# Install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
libmariadbclient-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install python dependencies | ||
COPY requirements.txt /app | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy project | ||
COPY ./crossreference /app/ | ||
|
||
# Add and run as non-root user | ||
RUN adduser --disabled-password --gecos '' cr | ||
USER cr | ||
|
||
# Run gunicorn | ||
CMD ["bash", "-c", "python manage.py collectstatic --noinput && exec gunicorn crossreference.wsgi:application --bind 0.0.0.0:25432"] |