Skip to content

Commit

Permalink
feat: switch to alpine based image (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quadrubo authored Jul 19, 2023
1 parent 549113d commit fd1eae8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
73 changes: 46 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
FROM serversideup/php:8.2-fpm-nginx
FROM ghcr.io/quadrubo/php-fpm-alpine-s6-nginx:php8.2-alpine3.18 as waky_builder

ARG NODE_VERSION=18
# Install node
ENV NODE_VERSION=18.16.0

# Add /config to allowed directory tree
ENV PHP_OPEN_BASEDIR=$WEBUSER_HOME:/config/:/dev/stdout:/tmp

# Enable mixed ssl mode so port 80 or 443 can be used
ENV SSL_MODE="mixed"
ENV NODE_PACKAGE_URL=https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64-musl.tar.xz

# Install additional packages and cron file
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
cron \
iputils-ping \
openssh-client \
# Needed for envsubst
gettext-base \
# Install cron file
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
# Install node & npm
&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
# Clean up package lists
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN apk update && \
apk add --no-cache libstdc++

# Copy package configs
COPY --chmod=755 docker/deploy/etc/s6-overlay/ /etc/s6-overlay/
RUN curl -fsSLO --compressed $NODE_PACKAGE_URL \
&& tar -xJf "node-v$NODE_VERSION-linux-x64-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
# fi
&& rm -f "node-v$NODE_VERSION-linux-x64-musl.tar.xz" \
# smoke tests
&& node --version \
&& npm --version

WORKDIR /var/www/html

Expand All @@ -49,4 +36,36 @@ RUN npm ci \
&& npm cache clean --force \
&& rm -rf node_modules

# main image
FROM ghcr.io/quadrubo/php-fpm-alpine-s6-nginx:php8.2-alpine3.18

# Add /config to allowed directory tree
ENV PHP_OPEN_BASEDIR=$WEBUSER_HOME:/config/:/dev/stdout:/tmp

# Enable mixed ssl mode so port 80 or 443 can be used
ENV SSL_MODE="mixed"

# Install additional packages and cron file
RUN apk update \
&& apk add --no-cache \
curl \
# cron \
iputils-ping \
openssh-client \
# Needed for envsubst
gettext \
# Install cron file
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /var/spool/cron/crontabs/root \
# Clean up package lists
# && apt-get clean \
&& rm -rf /tmp/* /var/tmp/* /usr/share/doc/*

# Copy package configs
COPY --chmod=755 docker/deploy/etc/s6-overlay/ /etc/s6-overlay/

WORKDIR /var/www/html

# Copy app
COPY --from=waky_builder --chown=webuser:webgroup /var/www/html /var/www/html/

VOLUME /config
2 changes: 1 addition & 1 deletion docker/deploy/etc/s6-overlay/s6-rc.d/cron/run
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/command/with-contenv bash
s6-setuidgid root /usr/sbin/cron -f -l 8
s6-setuidgid root /usr/sbin/crond -f -l 8
16 changes: 0 additions & 16 deletions docker/deploy/etc/s6-overlay/s6-rc.d/nginx/data/check

This file was deleted.

0 comments on commit fd1eae8

Please sign in to comment.