mirror of
https://github.com/librespeed/speedtest.git
synced 2024-11-25 16:52:58 +08:00
Merge pull request #631 from rare-magma/add-alpine-docker-image
Add alpine docker image version
This commit is contained in:
commit
79436f0f0d
25
.github/workflows/docker-publish.yml
vendored
25
.github/workflows/docker-publish.yml
vendored
@ -26,6 +26,16 @@ env:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- dockerfile: ./Dockerfile
|
||||
image: ghcr.io/${{ github.repository }}
|
||||
flavour: ""
|
||||
- dockerfile: ./Dockerfile.alpine
|
||||
image: ghcr.io/${{ github.repository }}
|
||||
flavour: "-alpine"
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@ -69,14 +79,16 @@ jobs:
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
images: ${{ matrix.image }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=ref,event=branch,suffix=${{ matrix.flavour }}
|
||||
type=ref,event=pr,suffix=${{ matrix.flavour }}
|
||||
# set latest tag for default branch
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest${{ matrix.flavour }},enable={{is_default_branch}}
|
||||
type=semver,pattern={{version}}${{ matrix.flavour }}
|
||||
type=semver,pattern={{major}}${{ matrix.flavour }}
|
||||
type=semver,pattern={{major}}.{{minor}}${{ matrix.flavour }}
|
||||
type=semver,pattern={{major}}.{{minor}}.{{patch}}${{ matrix.flavour }}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
@ -85,6 +97,7 @@ jobs:
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.dockerfile }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
@ -1,7 +1,7 @@
|
||||
FROM php:8-apache
|
||||
|
||||
# Install extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
@ -10,6 +10,12 @@ RUN apt-get update && apt-get install -y \
|
||||
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
|
||||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
||||
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
|
||||
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
|
||||
&& apt-get remove -y libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
libpq-dev \
|
||||
&& apt autoremove -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Prepare files and folders
|
||||
|
59
Dockerfile.alpine
Executable file
59
Dockerfile.alpine
Executable file
@ -0,0 +1,59 @@
|
||||
FROM php:8-alpine
|
||||
|
||||
# Install extensions
|
||||
RUN apk add --quiet --no-cache \
|
||||
bash \
|
||||
apache2 \
|
||||
apache2-ssl \
|
||||
php83-apache2 \
|
||||
php83-ctype \
|
||||
php83-openssl \
|
||||
freetype-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libpng-dev \
|
||||
libpq-dev \
|
||||
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
|
||||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
||||
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
|
||||
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
|
||||
&& apk del --quiet --no-cache \
|
||||
freetype-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libpng-dev \
|
||||
libpq-dev
|
||||
|
||||
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
|
||||
ln -sf /dev/stderr /var/log/apache2/error.log
|
||||
|
||||
# Prepare files and folders
|
||||
RUN mkdir -p /speedtest/
|
||||
|
||||
# Copy sources
|
||||
COPY backend/ /speedtest/backend
|
||||
|
||||
COPY results/*.php /speedtest/results/
|
||||
COPY results/*.ttf /speedtest/results/
|
||||
|
||||
COPY *.js /speedtest/
|
||||
COPY favicon.ico /speedtest/
|
||||
|
||||
COPY docker/servers.json /servers.json
|
||||
|
||||
COPY docker/*.php /speedtest/
|
||||
COPY docker/entrypoint.sh /
|
||||
|
||||
# Prepare default environment variables
|
||||
ENV TITLE=LibreSpeed
|
||||
ENV MODE=standalone
|
||||
ENV PASSWORD=password
|
||||
ENV TELEMETRY=false
|
||||
ENV ENABLE_ID_OBFUSCATION=false
|
||||
ENV REDACT_IP_ADDRESSES=false
|
||||
ENV WEBPORT=80
|
||||
|
||||
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
|
||||
STOPSIGNAL SIGWINCH
|
||||
|
||||
# Final touches
|
||||
EXPOSE 80
|
||||
CMD ["bash", "/entrypoint.sh"]
|
@ -12,6 +12,11 @@ cp /speedtest/*.js /var/www/html/
|
||||
# Copy favicon
|
||||
cp /speedtest/favicon.ico /var/www/html/
|
||||
|
||||
# Set custom webroot on alpine
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
sed -i "s#\"/var/www/localhost/htdocs\"#\"/var/www/html\"#g" /etc/apache2/httpd.conf
|
||||
fi
|
||||
|
||||
# Set up backend side for standlone modes
|
||||
if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then
|
||||
cp -r /speedtest/backend/ /var/www/html/backend
|
||||
@ -79,11 +84,19 @@ chown -R www-data /var/www/html/*
|
||||
|
||||
# Allow selection of Apache port for network_mode: host
|
||||
if [ "$WEBPORT" != "80" ]; then
|
||||
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
|
||||
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/httpd.conf
|
||||
else
|
||||
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
|
||||
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done, Starting APACHE"
|
||||
|
||||
# This runs apache
|
||||
exec apache2-foreground
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
exec httpd -DFOREGROUND
|
||||
else
|
||||
exec apache2-foreground
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user