-
Notifications
You must be signed in to change notification settings - Fork 5
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 #858 from Inter-Actief/docker-builds
Docker builds
- Loading branch information
Showing
7 changed files
with
146 additions
and
66 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,61 @@ | ||
name: Build docker image and run tests | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
services: | ||
mariadb: | ||
image: mariadb:10.2 | ||
env: | ||
MARIADB_USER: amelie_test | ||
MARIADB_PASSWORD: amelie_test | ||
MYSQL_DATABASE: amelie_test | ||
MYSQL_ROOT_PASSWORD: amelie_test | ||
ports: ['3306:3306'] | ||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Verify MariaDB connection | ||
run: | | ||
while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do | ||
sleep 1 | ||
done | ||
- name: Run Amelie tests | ||
run: | | ||
docker run --rm --entrypoint "/amelie/scripts/run_tests.sh" ghcr.io/inter-actief/amelie@${{ steps.push.outputs.digest }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
# Build the amelie docker image based on Debian 11 (Bullseye) | ||
FROM debian:bullseye | ||
|
||
# Install required debian packages for amelie | ||
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y apt-utils git net-tools python3 python3-pip mariadb-client libmariadb-dev xmlsec1 libssl-dev libldap-dev libsasl2-dev libjpeg-dev zlib1g-dev gettext | ||
|
||
# Enable nl_NL and en_US locales and rebuild locale | ||
RUN apt-get update && \ | ||
apt-get install -y locales && \ | ||
sed -i -e 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/' /etc/locale.gen && \ | ||
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ | ||
dpkg-reconfigure --frontend=noninteractive locales | ||
|
||
# Make directories for amelie | ||
RUN mkdir -p /amelie /amelie/static /media /photo_upload /config /var/log /var/run | ||
|
||
# Copy amelie sources | ||
COPY . /amelie | ||
|
||
# Set /amelie as startup working directory | ||
WORKDIR /amelie | ||
|
||
# Switch to root user | ||
USER root | ||
|
||
# Install python requirements | ||
RUN pip3 install -r requirements.txt | ||
|
||
# Install default configuration file | ||
RUN cp "/amelie/amelie/settings/local.py.default" "/amelie/amelie/settings/local.py" | ||
|
||
# Correct permissions on directories | ||
RUN chown -R 1000:1000 /amelie /media /photo_upload /config /var/log | ||
|
||
# Switch back to a local user | ||
USER 1000:1000 | ||
|
||
# Check if Django can run | ||
RUN python3 manage.py check | ||
|
||
# Expose volumes | ||
VOLUME ["/amelie/static", "/media", "/photo_upload", "/config"] | ||
|
||
# Expose the web port | ||
EXPOSE 80 | ||
|
||
# Start the website | ||
CMD ["/amelie/scripts/start_web.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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
#!/bin/bash | ||
|
||
# Print some debugging information about the environment | ||
# ------------------------------------------------------ | ||
# Python version | ||
python3 -V | ||
# Path to the python binary being used | ||
which python | ||
# Pip version | ||
pip -V | ||
# Path to the pip binary being used | ||
which pip | ||
# Installed pip package list | ||
pip freeze | ||
|
||
# Configure Django and run the tests | ||
# ---------------------------------- | ||
# Copy the test settings to local.py | ||
cp ./amelie/settings/tests.py ./amelie/settings/local.py | ||
|
||
# Run Django initial checks | ||
python3 manage.py check | ||
|
||
# Make sure staticfiles are collected into the static volume | ||
python3 manage.py collectstatic --noinput | ||
|
||
# Make sure database is migrated | ||
python3 manage.py migrate | ||
|
||
# Run Django tests | ||
python3 manage.py test --keepdb |