Skip to content

Commit a9aaa4f

Browse files
committed
Massively rewrite Docker image
- Image now runs FrankenPHP 1.9.x on PHP 8.4. - Initial configuration is to run Winter in "production" mode immediately. - Support for configuration through environment variables, including Backend URI and active theme. In addition, support for "_FILE" suffixed variables to load environment variables through secrets.
1 parent 08a8f5c commit a9aaa4f

File tree

15 files changed

+276
-1109
lines changed

15 files changed

+276
-1109
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
publish-docker-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Log in to the Container registry
20+
uses: docker/login-action@v2
21+
with:
22+
registry: ${{ env.REGISTRY }}
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Extract metadata (tags, labels) for Docker
27+
id: meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
31+
tags: |
32+
type=semver,pattern={{version}}
33+
type=semver,pattern={{major}}.{{minor}}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v4
37+
with:
38+
context: .
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
# Based off Dockerfile from TrafeX/docker-php-nginx (https://github.com/TrafeX/docker-php-nginx).
2-
# Credit to TrafeX for the original implementation.
3-
4-
FROM php:8.3.11-fpm-alpine3.20
5-
LABEL org.opencontainers.image.title="Winter CMS Docker Image - PHP 8.3.11 / Alpine 3.20"
1+
FROM dunglas/frankenphp:1.9-php8.4-trixie
2+
LABEL org.opencontainers.image.title="Winter CMS Docker Image - PHP 8.4 with FrankenPHP"
63
LABEL org.opencontainers.image.description="Builds and deploys a Winter CMS project using Docker."
74
LABEL org.opencontainers.image.source=https://github.com/wintercms/docker
85

9-
# Install PHP extension script
10-
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
6+
ARG USER=winter
7+
ARG WINTER_TAG=v1.2.8
118

12-
# Install PHP extensions
13-
RUN chmod +x /usr/local/bin/install-php-extensions && \
14-
install-php-extensions \
9+
RUN \
10+
# Install Microsoft packages key for SQL Server support
11+
curl -sSL -o /tmp/packages-microsoft-prod.deb https://packages.microsoft.com/config/debian/13/packages-microsoft-prod.deb \
12+
&& dpkg -i /tmp/packages-microsoft-prod.deb \
13+
&& rm /tmp/packages-microsoft-prod.deb \
14+
&& mkdir -p /opt/microsoft/msodbcsql18/ \
15+
&& touch /opt/microsoft/msodbcsql18/ACCEPT_EULA \
16+
&& apt update \
17+
# Install PHP extensions
18+
&& install-php-extensions \
1519
gd \
16-
gettext \
17-
imap \
1820
intl \
1921
memcached \
20-
opcache \
2122
pdo_mysql \
2223
pdo_pgsql \
2324
pdo_sqlsrv \
2425
pdo_odbc \
2526
redis \
26-
zip
27-
28-
# Install other software
29-
RUN apk add --no-cache \
30-
curl \
31-
git \
32-
nginx \
33-
supervisor \
34-
tar \
35-
unzip \
36-
zip
37-
27+
zip \
28+
# Install additional software for Composer
29+
&& apt update \
30+
&& apt install -y \
31+
git \
32+
unzip \
33+
tar \
34+
wget \
35+
# Clean up
36+
&& apt clean \
37+
&& rm -rf /var/lib/apt/lists/*
3838

3939
# Install Composer
4040
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
4141

42-
# Add configuration
43-
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf
44-
COPY config/nginx/default.conf /etc/nginx/conf.d/default.conf
45-
COPY config/php-fpm/php.ini /usr/local/etc/php/conf.d/docker-fpm.ini
46-
COPY config/php-fpm/docker.conf /usr/local/etc/php-fpm.d/docker.conf
47-
COPY config/php-fpm/pool.conf /usr/local/etc/php-fpm.d/www.conf
48-
COPY config/supervisor/supervisor.conf /etc/supervisor/conf.d/supervisord.conf
49-
RUN rm -f /usr/local/etc/php-fpm.d/zz-docker.conf
42+
# Setup Winter user and download Winter
43+
RUN \
44+
groupadd -g 10000 -r ${USER} \
45+
&& useradd -m -d /home/winter -u 10000 -g 10000 -s /bin/bash ${USER} \
46+
# Add additional capability to bind to port 80 and 443
47+
&& setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp \
48+
# Give write access to /config/caddy and /data/caddy
49+
&& chown -R ${USER}:${USER} /config/caddy /data/caddy \
50+
&& mkdir /winter \
51+
&& cd /winter \
52+
&& composer create-project --no-progress --no-interaction wintercms/winter /winter "${WINTER_TAG}" \
53+
&& chown -R ${USER}:${USER} /winter
5054

51-
# Create bootstrap directory and file
52-
COPY bootstrap /bootstrap
53-
COPY bootstrap.sh /bootstrap.sh
54-
55-
# Set the working directory
56-
RUN mkdir -p /winter
5755
WORKDIR /winter
56+
USER winter
5857

59-
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
60-
RUN chown -R nobody:nobody /winter /bootstrap /run /var/lib/nginx /var/log/nginx
61-
62-
# Switch to use a non-root user from here on
63-
USER nobody
64-
65-
# Expose the port Nginx is reachable on
66-
EXPOSE 8080
58+
ENV SERVER_NAME=":8000"
59+
ENV SERVER_ROOT="/winter/public"
60+
ENV APP_DEBUG="false"
61+
ENV APP_URL="http://localhost:8000"
62+
ENV ACTIVE_THEME="demo"
63+
ENV BACKEND_URI="backend"
64+
ENV ROUTES_CACHE="true"
65+
ENV ASSET_CACHE="true"
6766

68-
CMD ["/bootstrap.sh"]
67+
COPY entrypoint.sh /entrypoint.sh
68+
COPY config/php.ini /usr/local/etc/php/conf.d/winter.ini
6969

70-
# Configure a healthcheck to validate that everything is up&running
71-
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping || exit 1
70+
CMD ["--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"]
71+
ENTRYPOINT ["/entrypoint.sh"]

bootstrap.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

bootstrap/bootstrap.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

bootstrap/lib/Env.php

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)