-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c91422
commit 7e1bf99
Showing
13 changed files
with
425 additions
and
6 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
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
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,4 @@ | ||
PLATFORM=linux/amd64 | ||
PHP_VERSION=8.4.1 | ||
PHP_VERSION_MAJOR=8.4 | ||
ALPINE_VERSION=3.20 |
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,102 @@ | ||
# Load the PHP version and Alpine version from the .env file | ||
ARG PHP_VERSION=${PHP_VERSION} | ||
ARG ALPINE_VERSION=${ALPINE_VERSION} | ||
|
||
# Pull the PHP image with the specified version and Alpine version | ||
FROM --platform=$TARGETPLATFORM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION} | ||
|
||
# Redefine the ARGs after FROM | ||
|
||
ARG PHP_VERSION | ||
ARG ALPINE_VERSION | ||
|
||
# Add Repositories | ||
RUN rm -f /etc/apk/repositories &&\ | ||
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" >> /etc/apk/repositories && \ | ||
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories | ||
|
||
# upgrade | ||
RUN apk update && \ | ||
apk upgrade | ||
|
||
# Add Build Dependencies | ||
RUN apk add --no-cache --virtual .build-deps \ | ||
zlib-dev \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
libxml2-dev \ | ||
bzip2-dev \ | ||
zip \ | ||
libwebp-dev \ | ||
openssl-dev | ||
|
||
|
||
# Add App Dependencies | ||
RUN apk add --update --no-cache \ | ||
jpegoptim \ | ||
pngquant \ | ||
optipng \ | ||
vim \ | ||
mysql-client \ | ||
bash \ | ||
shared-mime-info \ | ||
zip \ | ||
git \ | ||
curl \ | ||
wget \ | ||
gcompat \ | ||
icu-dev \ | ||
freetype-dev \ | ||
libzip-dev \ | ||
bzip2 \ | ||
libwebp \ | ||
libpng \ | ||
fcgi \ | ||
su-exec \ | ||
shadow \ | ||
rsync \ | ||
linux-headers | ||
|
||
# Configure & Install Extension | ||
RUN docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ --with-webp=/usr/include/ && \ | ||
docker-php-ext-install \ | ||
bcmath \ | ||
bz2 \ | ||
gd \ | ||
intl \ | ||
mysqli \ | ||
pcntl \ | ||
pdo_mysql \ | ||
sockets \ | ||
zip \ | ||
&& apk del -f .build-deps | ||
|
||
ARG HOST_USER_GID | ||
ARG HOST_USER_UID | ||
|
||
LABEL afterapk="php-cli-alpine-$PHP_VERSION" | ||
|
||
ARG HOST_ENV=development | ||
|
||
|
||
|
||
# Install Composer with the filename 'composer2' | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 | ||
|
||
# Create a symbolic link named 'composer' that points to 'composer2' | ||
RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer | ||
|
||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
ENV PATH="./vendor/bin:$PATH" | ||
|
||
# Setup Working Dir to model BH | ||
WORKDIR / | ||
|
||
# Copy entrypoint script | ||
COPY _shared/entrypoint.sh /usr/local/bin/entrypoint | ||
|
||
# Set permissions for the entrypoint script | ||
RUN chmod +x /usr/local/bin/entrypoint | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["entrypoint"] |
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,78 @@ | ||
# cross platform alpine-based php* images | ||
|
||
|
||
|
||
### required ENV | ||
|
||
make sure these ENV varaiables exist on your host-machine | ||
|
||
``` | ||
HOST_USER_GID | ||
HOST_USER_UID | ||
``` | ||
#### set these env vars | ||
|
||
ie on `macOS` in `~/.extra` or `~/.bash_profile` | ||
|
||
get `HOST_USER_UID` | ||
|
||
``` | ||
id -u | ||
``` | ||
|
||
|
||
get `HOST_USER_GID` | ||
``` | ||
id -g | ||
``` | ||
|
||
|
||
### run | ||
``` | ||
echo "export HOST_USER_GID=$(id -g)" >> ~/.bash_profile && echo "export HOST_USER_UID=$(id -u)" >> ~/.bash_profile && echo "export DOCKER_USER=$(id -u):$(id -g)" >> ~/.bash_profile | ||
``` | ||
|
||
|
||
### optional ENV | ||
|
||
this will enable opcache and php.ini production settings | ||
|
||
```ini | ||
HOST_ENV=production | ||
``` | ||
|
||
|
||
docker-compose.yml | ||
```yaml | ||
php80: | ||
image: mxmb/php:8.4-cli | ||
# optional: disable if you're running behind a proxy like traefik | ||
ports: | ||
- "9000:9000" | ||
volumes: | ||
# real time sync for app php files | ||
- .:/app | ||
# cache laravel libraries dir | ||
- ./vendor:/app/vendor:cached | ||
# logs and sessions should be authorative inside docker | ||
- ./storage:/app/storage:delegated | ||
# cache static assets bc cli doesn't need to update css or js | ||
- ./public:/app/public:cached | ||
# additional php config REQUIRED | ||
- ./docker-conf/php-ini:/usr/local/etc/php/custom.d | ||
env_file: | ||
- .env | ||
environment: | ||
# note that apline has dif dir structures: /user/local/etc - conf.d need to be scanned here for all modules from image | ||
- PHP_INI_SCAN_DIR=/usr/local/etc/php/conf.d/:/usr/local/etc/php/custom.d | ||
# composer settings | ||
- COMPOSER_AUTH=${COMPOSER_AUTH} | ||
- COMPOSER_ALLOW_SUPERUSER=1 | ||
# these are CRITICAL | ||
- HOST_USER_UID=${HOST_USER_UID:-1000} | ||
- HOST_USER_GID=${HOST_USER_GID:-1000} | ||
# enables opache in prod | ||
- HOST_ENV=${HOST_ENV:-production} | ||
# this should only be used in troubleshooting | ||
- EXEC_AS_ROOT=0 | ||
``` |
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.8' | ||
|
||
services: | ||
php83-alpine: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
PLATFORM: ${PLATFORM} | ||
PHP_VERSION: ${PHP_VERSION} | ||
ALPINE_VERSION: ${ALPINE_VERSION} | ||
image: madebymode/php83-cli-alpine:latest | ||
environment: | ||
HOST_ENV: development | ||
HOST_USER_UID: 1000 | ||
HOST_USER_GID: 1000 |
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,4 @@ | ||
PLATFORM=linux/amd64 | ||
PHP_VERSION=8.4.1 | ||
PHP_VERSION_MAJOR=8.4 | ||
ALPINE_VERSION=3.20 |
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,119 @@ | ||
# Load the PHP version and Alpine version from the .env file | ||
ARG PHP_VERSION=${PHP_VERSION} | ||
ARG ALPINE_VERSION=${ALPINE_VERSION} | ||
|
||
# Pull the PHP image with the specified version and Alpine version | ||
FROM --platform=$TARGETPLATFORM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION} | ||
|
||
# Redefine the ARGs after FROM | ||
|
||
ARG PHP_VERSION | ||
ARG ALPINE_VERSION | ||
ENV DISABLE_HEALTHCHECK=false | ||
|
||
# Add Repositories | ||
RUN rm -f /etc/apk/repositories &&\ | ||
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" >> /etc/apk/repositories && \ | ||
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories | ||
|
||
# upgrade | ||
RUN apk update && \ | ||
apk upgrade | ||
|
||
# Add Build Dependencies | ||
RUN apk add --no-cache --virtual .build-deps \ | ||
zlib-dev \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
libxml2-dev \ | ||
bzip2-dev \ | ||
zip \ | ||
libwebp-dev \ | ||
openssl-dev | ||
|
||
|
||
# Add App Dependencies | ||
RUN apk add --update --no-cache \ | ||
jpegoptim \ | ||
pngquant \ | ||
optipng \ | ||
vim \ | ||
mysql-client \ | ||
bash \ | ||
shared-mime-info \ | ||
zip \ | ||
git \ | ||
curl \ | ||
wget \ | ||
gcompat \ | ||
icu-dev \ | ||
freetype-dev \ | ||
libzip-dev \ | ||
bzip2 \ | ||
libwebp \ | ||
libpng \ | ||
fcgi \ | ||
su-exec \ | ||
shadow \ | ||
rsync \ | ||
linux-headers | ||
|
||
# Configure & Install Extension | ||
RUN docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ --with-webp=/usr/include/ && \ | ||
docker-php-ext-install \ | ||
bcmath \ | ||
bz2 \ | ||
gd \ | ||
intl \ | ||
mysqli \ | ||
pcntl \ | ||
pdo_mysql \ | ||
sockets \ | ||
zip \ | ||
opcache \ | ||
&& apk del -f .build-deps | ||
|
||
ARG HOST_USER_GID | ||
ARG HOST_USER_UID | ||
|
||
LABEL afterapk="php-fpm-alpine-$PHP_VERSION" | ||
|
||
ARG HOST_ENV=development | ||
|
||
# Create and configure status.conf for PHP-FPM status page | ||
RUN echo '[www]' > /usr/local/etc/php-fpm.d/status.conf && \ | ||
echo 'pm.status_path = /status' >> /usr/local/etc/php-fpm.d/status.conf | ||
|
||
# Health check script | ||
COPY _shared/php-fpm-healthcheck /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/php-fpm-healthcheck | ||
|
||
|
||
|
||
# Install Composer with the filename 'composer2' | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 | ||
|
||
# Create a symbolic link named 'composer' that points to 'composer2' | ||
RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer | ||
|
||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
ENV PATH="./vendor/bin:$PATH" | ||
|
||
# Setup Working Dir to model BH | ||
WORKDIR / | ||
|
||
# Add a condition for the health check | ||
HEALTHCHECK --interval=5s --timeout=1s \ | ||
CMD if [ -z "$DISABLE_HEALTHCHECK" ]; then php-fpm-healthcheck || exit 1; else exit 0; fi | ||
|
||
# Copy entrypoint script | ||
COPY _shared/entrypoint.sh /usr/local/bin/entrypoint | ||
|
||
# Set permissions for the entrypoint script | ||
RUN chmod +x /usr/local/bin/entrypoint | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["entrypoint"] | ||
|
||
# Set default command | ||
CMD ["php-fpm", "-F"] |
Oops, something went wrong.