-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from alan-turing-institute/7-add-docker-image
Add docker image
- Loading branch information
Showing
7 changed files
with
160 additions
and
18 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,44 @@ | ||
--- | ||
name: Build and publish a Docker image | ||
|
||
# Run workflow on pushes to matching branches | ||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: ["main"] | ||
tags: ["*"] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-publish-image: | ||
name: Build Docker image and publish to GitHub container repository | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
- name: Build and publish Docker images | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,25 @@ | ||
FROM python:3.11-alpine | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add --update --no-cache \ | ||
gcc libc-dev libffi-dev | ||
|
||
# Upload and install Python package and dependencies | ||
COPY ./apricot apricot | ||
COPY ./pyproject.toml . | ||
COPY ./README.md . | ||
RUN pip install --upgrade hatch pip | ||
# Initialise environment with hatch | ||
RUN hatch run true | ||
|
||
# Install executable files and set permissions | ||
COPY ./docker/entrypoint.sh . | ||
COPY ./run.py . | ||
RUN chmod ugo+x ./entrypoint.sh | ||
|
||
# Open appropriate ports | ||
EXPOSE 1389 | ||
|
||
# Run the server | ||
ENTRYPOINT ["./entrypoint.sh"] |
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
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,16 @@ | ||
--- | ||
version: "3" | ||
services: | ||
apricot: | ||
container_name: apricot | ||
image: apricot | ||
build: . | ||
environment: | ||
BACKEND: "MicrosoftEntra" | ||
CLIENT_ID: "<your OpenID client ID here" | ||
CLIENT_SECRET: "<your OpenID client secret here>" | ||
DOMAIN: "<your domain here>" | ||
ENTRA_TENANT_ID: "<your Entra tenant ID here>" | ||
ports: | ||
- "1389:1389" | ||
restart: always |
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,38 @@ | ||
#! /bin/sh | ||
# shellcheck disable=SC2086 | ||
# shellcheck disable=SC2089 | ||
|
||
if [ -z "${BACKEND}" ]; then | ||
echo "BACKEND environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${CLIENT_ID}" ]; then | ||
echo "CLIENT_ID environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${CLIENT_SECRET}" ]; then | ||
echo "CLIENT_SECRET environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${DOMAIN}" ]; then | ||
echo "DOMAIN environment variable is not set" | ||
exit 1 | ||
fi | ||
|
||
# Optional arguments | ||
EXTRA_OPTS="" | ||
if [ -n "${ENTRA_TENANT_ID}" ]; then | ||
EXTRA_OPTS="${EXTRA_OPTS} --entra-tenant-id $ENTRA_TENANT_ID" | ||
fi | ||
|
||
# Run the server | ||
hatch run python run.py \ | ||
--backend "$BACKEND" \ | ||
--client-id "$CLIENT_ID" \ | ||
--client-secret "$CLIENT_SECRET" \ | ||
--domain "$DOMAIN" \ | ||
--port 1389 \ | ||
$EXTRA_OPTS |
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
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