Skip to content

Commit

Permalink
Updated build config
Browse files Browse the repository at this point in the history
  • Loading branch information
shinsenter committed Mar 8, 2022
1 parent 817f106 commit 370ecfc
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 47 deletions.
37 changes: 18 additions & 19 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ jobs:
env:
DOCKER_BUILDKIT: "1"
steps:
- id: config
run: |
echo "::set-output name=s6_version::$(cat S6_VERSION.txt)"
echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- run: |
- id: config
run: |
./.git-config/hooks/pre-commit
mkdir -p /tmp/buildx
cat versions/base.txt
echo "::set-output name=s6_version::$(cat S6_VERSION.txt)"
echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/cache@v2
with:
path: /tmp/buildx
Expand All @@ -74,7 +73,7 @@ jobs:
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx-new,mode=max
context: "{{defaultContext}}:src/base/"
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/base.txt') }}
BASE_IMAGE=${{ matrix.base }}:${{ matrix.version }}
Expand Down Expand Up @@ -105,16 +104,16 @@ jobs:
env:
DOCKER_BUILDKIT: "1"
steps:
- id: config
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- run: |
- id: config
run: |
./.git-config/hooks/pre-commit
mkdir -p /tmp/buildx
cat versions/cli.txt
cat versions/fpm.txt
echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/cache@v2
with:
path: /tmp/buildx
Expand All @@ -132,7 +131,7 @@ jobs:
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx,mode=max
context: "{{defaultContext}}:src/php/cli/"
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/cli.txt') }}
BASE_IMAGE=shinsenter/s6-ubuntu:focal
Expand All @@ -149,7 +148,7 @@ jobs:
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx-new,mode=max
context: "{{defaultContext}}:src/php/fpm/"
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/fpm.txt') }}
BASE_IMAGE=${{ matrix.image }}
Expand Down Expand Up @@ -183,15 +182,15 @@ jobs:
env:
DOCKER_BUILDKIT: "1"
steps:
- id: config
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- run: |
- id: config
run: |
./.git-config/hooks/pre-commit
mkdir -p /tmp/buildx
cat versions/servers.txt
echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/cache@v2
with:
path: /tmp/buildx
Expand All @@ -209,7 +208,7 @@ jobs:
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx-new,mode=max
context: "{{defaultContext}}:src/servers/${{ matrix.variation }}/"
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/servers.txt') }}
BASE_IMAGE=${{ matrix.image }}
Expand Down Expand Up @@ -244,15 +243,15 @@ jobs:
env:
DOCKER_BUILDKIT: "1"
steps:
- id: config
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- run: |
- id: config
run: |
./.git-config/hooks/pre-commit
mkdir -p /tmp/buildx
cat versions/webapps.txt
echo "::set-output name=date::$(date +'%Y%m%d')"
- uses: actions/cache@v2
with:
path: /tmp/buildx
Expand All @@ -270,7 +269,7 @@ jobs:
cache-from: type=local,src=/tmp/buildx
cache-to: type=local,dest=/tmp/buildx-new,mode=max
context: "{{defaultContext}}:src/webapps/${{ matrix.app }}/"
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_NUMBER=${{ steps.config.outputs.date }}-${{ hashFiles('versions/webapps.txt') }}
BASE_IMAGE=shinsenter/php
Expand Down
2 changes: 1 addition & 1 deletion src/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ ENV S6_SERVICES_GRACETIME=3000

ARG BUILD_NUMBER
LABEL build_number="$BUILD_NUMBER"
LABEL publisher="https://hub.docker.com/u/shinsenter"
LABEL maintainer="[email protected]"
LABEL publisher="https://hub.docker.com/u/shinsenter"
2 changes: 1 addition & 1 deletion src/base/root/etc/cont-init.d/000-update-webuser
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ if [[ $PUID != 9999 || $PGID != 9999 ]]; then
/usr/sbin/usermod -o -u $PUID webuser
fi

if [ ! -z "$WEBHOME" ] && [ ! -e "$WEBHOME" ]; then
if [ ! -z "$WEBHOME" ]; then
webuser-mkdir $WEBHOME
fi
8 changes: 5 additions & 3 deletions src/base/root/etc/cont-init.d/999-fix-permission
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
WEBHOME="${WEBHOME:-/var/www/html}"

if [ "$FIX_WEBHOME_PERMISSION" == "true" ] || [ -e /tmp/cleanup ]; then
echo
echo "🗂 Fixing permission for ${WEBHOME}..."
webuser-mkdir $WEBHOME recursive
if [ ! -z "$WEBHOME" ]; then
echo
echo "🗂 Fixing permission for ${WEBHOME}..."
webuser-mkdir $WEBHOME recursive
fi
rm -f /tmp/cleanup
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

WEBHOME="${WEBHOME:-/var/www/html}"

echo
/usr/sbin/php-fpm -v

su webuser

if [ -f $WEBHOME/composer.json ] && [ ! -e $WEBHOME/vendor/ ]; then
echo
echo "🤖 Installing packages from $WEBHOME/composer.json..."
dirty
/usr/bin/composer install -d $WEBHOME/ \
Expand All @@ -13,8 +19,4 @@ if [ -f $WEBHOME/composer.json ] && [ ! -e $WEBHOME/vendor/ ]; then
fi

echo
/usr/sbin/php-fpm -v

echo
su webuser
/usr/sbin/php-fpm --nodaemonize
7 changes: 5 additions & 2 deletions src/servers/fpm-apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ ARG APACHE_PPA_KEY="4F4EA0AAE5267A6C"
ARG APACHE_PPA_URL="http://ppa.launchpadcontent.net/ondrej/apache2/ubuntu"
ARG APACHE_SOURCES="/etc/apt/sources.list.d/ondrej-apache.list"

ARG APACHE_RUN_GROUP=webgroup
ARG APACHE_RUN_USER=webuser
ARG APACHE_RUN_GROUP="webgroup"
ARG APACHE_RUN_USER="webuser"
ENV WEBHOME="/var/www/html"
ENV APACHE_DOCUMENT_ROOT=""

RUN echo "Installing Apache..." \
\
Expand All @@ -29,6 +31,7 @@ RUN echo "Installing Apache..." \
&& echo "ServerName localhost" >>/etc/apache2/apache2.conf \
&& sed -i 's/LogFormat "%h %l %u %t \\\"%r\\\" %>s %O \\\"/LogFormat "%a %l %u %t \\\"%r\\\" %>s %O \\\"/' /etc/apache2/apache2.conf \
&& echo >>/etc/apache2/envvars \
&& echo "export DOCUMENT_ROOT=\"${WEBHOME}\${APACHE_DOCUMENT_ROOT}\"" >>/etc/apache2/envvars \
&& echo "export APACHE_RUN_USER=${APACHE_RUN_USER}" >>/etc/apache2/envvars \
&& echo "export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}" >>/etc/apache2/envvars \
&& rm -f ${WEBHOME}/*.html \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RemoteIPHeader CF-Connecting-IP

# Configure main document root
DocumentRoot ${WEBHOME}${APACHE_DOCUMENT_ROOT}
DocumentRoot ${DOCUMENT_ROOT}

# Set basic settings for document root. Configure correct directory indexes and disable directory browsing
<Directory ${WEBHOME}>
Expand Down Expand Up @@ -47,7 +47,7 @@
Protocols h2 http/1.1

# Configure main document root
DocumentRoot ${WEBHOME}${APACHE_DOCUMENT_ROOT}
DocumentRoot ${DOCUMENT_ROOT}

# Set basic settings for document root.
# Configure correct directory indexes and disable directory browsing
Expand Down
3 changes: 3 additions & 0 deletions src/servers/fpm-nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ ARG NGINX_PPA_KEY="4F4EA0AAE5267A6C"
ARG NGINX_PPA_URL="http://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu"
ARG NGINX_SOURCES="/etc/apt/sources.list.d/ondrej-nginx.list"

ENV WEBHOME="/var/www/html"
ENV NGINX_DOCUMENT_ROOT=""

RUN echo "Installing Nginx..." \
\
# adds ondrej repos for Nginx
Expand Down
6 changes: 3 additions & 3 deletions src/webapps/codeigniter4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ FROM ${BASE_IMAGE}:${PHP_VERSION}-fpm-apache
ADD root/ /

# updates document root path
ENV WEBHOME=/var/www/html
ENV APACHE_DOCUMENT_ROOT=/public
ENV WEBHOME="/var/www/html"
ENV APACHE_DOCUMENT_ROOT="/public"

# sets the working directory
WORKDIR /var/www/html/
WORKDIR $WEBHOME

################################################################################

Expand Down
6 changes: 3 additions & 3 deletions src/webapps/laravel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ RUN apt-update && apt-install php${PHP_VERSION}-swoole \
ADD root/ /

# updates document root path
ENV WEBHOME=/var/www/html
ENV NGINX_DOCUMENT_ROOT=/public
ENV WEBHOME="/var/www/html"
ENV NGINX_DOCUMENT_ROOT="/public"

# sets the working directory
WORKDIR /var/www/html/
WORKDIR $WEBHOME

################################################################################

Expand Down
4 changes: 2 additions & 2 deletions src/webapps/phpmyadmin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ FROM ${BASE_IMAGE}:${PHP_VERSION}-fpm-nginx
ADD root/ /

# updates document root path
ENV WEBHOME=/var/www/html
ENV NGINX_DOCUMENT_ROOT=
ENV WEBHOME="/var/www/html"
ENV NGINX_DOCUMENT_ROOT=""

# sets the working directory
WORKDIR $WEBHOME
Expand Down
6 changes: 3 additions & 3 deletions src/webapps/symfony/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ FROM ${BASE_IMAGE}:${PHP_VERSION}-fpm-nginx
ADD root/ /

# updates document root path
ENV WEBHOME=/var/www/html
ENV NGINX_DOCUMENT_ROOT=/public
ENV WEBHOME="/var/www/html"
ENV NGINX_DOCUMENT_ROOT="/public"

# sets the working directory
WORKDIR /var/www/html/
WORKDIR $WEBHOME

################################################################################

Expand Down
4 changes: 2 additions & 2 deletions src/webapps/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ COPY --from=source /usr/bin/wp-cli /usr/bin/wp-cli
ADD root/ /

# updates document root path
ENV WEBHOME=/var/www/html
ENV APACHE_DOCUMENT_ROOT=
ENV WEBHOME="/var/www/html"
ENV APACHE_DOCUMENT_ROOT=""

# sets the working directory
WORKDIR $WEBHOME
Expand Down
2 changes: 1 addition & 1 deletion tests/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
##############################################################################

common:
platform: ${BUILD_PLATFORM:-linux/arm/v6}
platform: ${BUILD_PLATFORM:-linux/arm64/v8}
environment:
- PUID=1234
- PGID=1234
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TEST_DIR="$BASE_DIR/tests"
export DOCKER_BUILDKIT=1
export S6_VERSION="$(cat $BASE_DIR/S6_VERSION.txt)"
export PHP_VERSION="${1:-8.1}"
export BUILD_PLATFORM="${2:-linux/arm/v6}"
export BUILD_PLATFORM="${2:-linux/arm64/v8}"

clear
$BASE_DIR/.git-config/hooks/pre-commit
Expand Down

0 comments on commit 370ecfc

Please sign in to comment.