From acaaeae07b9fc8871da5e8d0b77530399515c171 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Thu, 20 Oct 2022 13:42:52 +0200 Subject: [PATCH] init --- .drone.yml | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 41 +++++++++++++++++++++++++ README.md | 43 ++++++++++++++++++++++++++ build.sh | 9 ++++++ rebuild.sh | 14 +++++++++ start.sh | 10 ++++++ 6 files changed, 207 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build.sh create mode 100755 rebuild.sh create mode 100755 start.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fbf9aae --- /dev/null +++ b/.drone.yml @@ -0,0 +1,90 @@ +kind: pipeline +type: docker +name: build + +steps: + - name: build + image: docker:dind + volumes: + - name: dockersock + path: /var/run + environment: + DOCKER_USERNAME: + from_secret: docker_username + DOCKER_PASSWORD: + from_secret: docker_password + commands: + - sleep 5 # give docker enough time to start + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - ./build.sh + when: + branch: + - master + event: + - push + +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + command: + - dockerd-entrypoint.sh + - dockerd + - --host=unix:///var/run/docker.sock + - --mtu=1492 + +volumes: + - name: dockersock + temp: {} + +trigger: + branch: + - master + event: + - push +--- +kind: pipeline +type: docker +name: rebuild + +steps: + - name: rebuild + image: docker:dind + volumes: + - name: dockersock + path: /var/run + environment: + DOCKER_USERNAME: + from_secret: docker_username + DOCKER_PASSWORD: + from_secret: docker_password + commands: + - sleep 5 # give docker enough time to start + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - ./rebuild.sh + +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + command: + - dockerd-entrypoint.sh + - dockerd + - --host=unix:///var/run/docker.sock + - --mtu=1492 + +volumes: + - name: dockersock + temp: {} + +trigger: + event: + - cron + cron: + - rebuild diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0425943 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM debian:bookworm-slim + +RUN set -eux && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + vim \ + locales \ + openssl \ + ca-certificates \ + net-tools \ + curl \ + apache2 \ + libapache2-mpm-itk \ + libapache2-mod-fcgid \ + php8.1-cli \ + php8.1-curl \ + php8.1-pgsql \ + php8.1-mysql \ + php8.1-sqlite3 \ + php8.1-gd \ + php8.1-mbstring \ + php8.1-zip \ + php8.1-fpm \ + php-pear \ + && \ + ln -sf /dev/stdout /var/log/apache2/access.log && \ + ln -sf /dev/stderr /var/log/apache2/error.log && \ + /usr/sbin/a2enmod remoteip rewrite proxy proxy_fcgi && \ + rm -rf /var/lib/apt/lists/* && \ + echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \ + /usr/sbin/locale-gen && \ + /usr/sbin/update-locale 'LANG=en_US.UTF-8' + +ADD start.sh / + +EXPOSE 80/tcp + +CMD /start.sh + +HEALTHCHECK CMD netstat -tnlp | grep '0.0.0.0:80' || exit 1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..61d529b --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Apache2 ITK MPM + PHP Docker container + +* Debian slim based image +* Apache 2 + ITK MPM +* PHP + +# Supported tags and respective `Dockerfile` links + +- [`latest`](https://git.nethuis.nl/pommi/docker-apache2-itk-php/Dockerfile) + +# Usage + +## Environment variables + +| Key | Format | Description | +| --- | --- | --- | + +## docker run + +``` +$ docker run -it \ + --name apache2-itk-php \ + -p 8080:80 \ + --cap-add=SYS_NICE \ + --cap-add=DAC_READ_SEARCH \ + pommib/apache2-itk-php:latest +``` + +## docker-compose + +``` +version: "3" + +services: + apache2-itk-php: + container_name: apache2-itk-php + image: pommib/apache2-itk-php:latest + cap_add: + - SYS_NICE + - DAC_READ_SEARCH + ports: + - "8080:80/tcp" +``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4e80666 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -ex + +IMAGE=pommib/apache2-itk-php:latest +docker pull $IMAGE +docker pull debian:bookworm-slim +docker build --no-cache -t $IMAGE ./ +docker push $IMAGE diff --git a/rebuild.sh b/rebuild.sh new file mode 100755 index 0000000..fff1614 --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +updates_available () { + docker pull "$1" + if test "$(docker run -it --rm "$1" /bin/sh -c 'apt -qqq update && apt -qq list --upgradable')" != ""; then + return 0 + else + return 1 + fi +} + +if updates_available pommib/apache2-itk-php:latest; then + ./build.sh +fi diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..3906248 --- /dev/null +++ b/start.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -ex + +/usr/sbin/php-fpm8.1 --nodaemonize --fpm-config /etc/php/8.1/fpm/php-fpm.conf & + +/usr/sbin/apache2ctl -D FOREGROUND & + +wait -n + +exit $?