Skip to content

Commit 098b0bc

Browse files
committed
Improve build by not building from sources
1 parent 0ed8ce6 commit 098b0bc

File tree

3 files changed

+89
-61
lines changed

3 files changed

+89
-61
lines changed
Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
1-
name: Publish Docker image to ghcr.io
2-
on:
3-
# publish on releases (tagged as "x.y.z" - "v" prefix is removed)
4-
release:
5-
types: [published]
1+
name: Build and Push PHP+Composer Images
62

7-
# publish on pushes to the main branch
3+
on:
84
push:
95
branches:
106
- main
11-
12-
env:
13-
REGISTRY: ghcr.io
14-
IMAGE_NAME: ${{ github.repository }}
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Image tag (e.g. 8.2-2.2)"
11+
required: true
1512

1613
jobs:
17-
build-and-push-image:
14+
build:
1815
runs-on: ubuntu-latest
16+
1917
permissions:
2018
contents: read
2119
packages: write
2220

2321
steps:
24-
- name: Checkout repository
22+
- name: Checkout code
2523
uses: actions/checkout@v4
2624

27-
- name: Log in to the Container registry
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to GitHub Container Registry
2829
uses: docker/login-action@v3
2930
with:
30-
registry: ${{ env.REGISTRY }}
31+
registry: ghcr.io
3132
username: ${{ github.actor }}
3233
password: ${{ secrets.GITHUB_TOKEN }}
3334

34-
- name: Set up Docker Buildx
35-
uses: docker/setup-buildx-action@v3
36-
37-
- name: Build and push Docker image
35+
- name: Build and push multi-arch image
3836
uses: docker/build-push-action@v6
3937
with:
4038
context: .
41-
file: ./Dockerfile
4239
push: true
43-
tags: ${{ github.repository }}
44-
platforms: linux/amd64,linux/arm64,linux/arm/v7
40+
platforms: linux/amd64,linux/arm64
41+
tags: |
42+
ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}

Dockerfile

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
1-
FROM node:22-alpine AS node
2-
FROM php:8.2-cli-alpine
1+
FROM ubuntu:22.04
32

4-
RUN apk add --no-cache libstdc++ libgcc jq git curl unzip sshpass openssh-client rsync bash
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
# Allow PHP version and composer version to be overriden
6+
ARG PHP_VERSION=8.2
7+
ARG COMPOSER_VERSION=2.2
8+
9+
ENV LANG=en_US.UTF-8 \
10+
LC_ALL=en_US.UTF-8 \
11+
# keep the daemons quiet(er)
12+
ES_JAVA_OPTS="-Xms512m -Xmx512m"
13+
14+
ENV CI=true
15+
16+
RUN apt-get update && \
17+
apt-get install -y --no-install-recommends \
18+
lsb-release ca-certificates curl wget gnupg2 software-properties-common \
19+
apt-transport-https locales patch diffutils \
20+
unzip zip git jq patch ssh-client vim rsync && \
21+
locale-gen en_US.UTF-8 && \
22+
update-locale LANG=en_US.UTF-8
23+
24+
25+
# PHP (Ondřej Surý PPA – gives every version 7.2-8.4) :contentReference[oaicite:0]{index=0}
26+
RUN add-apt-repository -y ppa:ondrej/php
27+
28+
RUN mkdir -p /run/php && \
29+
apt-get update && \
30+
apt-get install -y --no-install-recommends \
31+
# PHP core + typical Magento extensions
32+
php${PHP_VERSION} \
33+
php${PHP_VERSION}-fpm \
34+
php${PHP_VERSION}-cli \
35+
php${PHP_VERSION}-bcmath \
36+
php${PHP_VERSION}-bz2 \
37+
php${PHP_VERSION}-curl \
38+
php${PHP_VERSION}-gd \
39+
php${PHP_VERSION}-intl \
40+
php${PHP_VERSION}-mbstring \
41+
php${PHP_VERSION}-mysql \
42+
php${PHP_VERSION}-mysqli \
43+
php${PHP_VERSION}-xml \
44+
php${PHP_VERSION}-zip \
45+
php${PHP_VERSION}-opcache \
46+
php${PHP_VERSION}-soap \
47+
php${PHP_VERSION}-ftp \
48+
php${PHP_VERSION}-xsl \
49+
php${PHP_VERSION}-sockets \
50+
php${PHP_VERSION}-exif \
51+
# misc
52+
tzdata && \
53+
apt-get clean && rm -rf /var/lib/apt/lists/*
54+
55+
# Install Node 22
56+
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash - && \
57+
apt-get install -y nodejs && \
58+
node --version && \
59+
npm --version
560

661
# Install Composer
7-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --2.2
8-
9-
# Install PHP extensions
10-
RUN apk add --no-cache \
11-
# Install dependencies for PHP extensions
12-
oniguruma-dev icu-dev libxml2-dev libpng-dev libjpeg-turbo-dev freetype-dev libxslt-dev \
13-
libzip-dev zip zlib-dev libmcrypt-dev gmp-dev libintl linux-headers patch diffutils
14-
15-
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
16-
&& docker-php-ext-install -j$(nproc) \
17-
bcmath \
18-
ctype \
19-
dom \
20-
fileinfo \
21-
gd \
22-
intl \
23-
mbstring \
24-
opcache \
25-
pcntl \
26-
pdo_mysql \
27-
simplexml \
28-
soap \
29-
xsl \
30-
zip \
31-
sockets \
32-
&& docker-php-ext-enable bcmath ctype dom fileinfo gd intl mbstring opcache pcntl pdo_mysql simplexml soap xsl zip sockets
33-
34-
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
35-
COPY --from=node /usr/local/include/node /usr/local/include/node
36-
COPY --from=node /usr/local/share/man/man1/node.1 /usr/local/share/man/man1/node.1
37-
COPY --from=node /usr/local/share/doc/node /usr/local/share/doc/node
38-
COPY --from=node /usr/local/bin/node /usr/local/bin/node
39-
COPY --from=node /opt/ /opt/
40-
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
41-
RUN ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
42-
RUN ln -s /opt/yarn-$(ls /opt/ | grep yarn | sed 's/yarn-//')/bin/yarn /usr/local/bin/yarn
43-
RUN ln -s /opt/yarn-$(ls /opt/ | grep yarn | sed 's/yarn-//')/bin/yarnpkg /usr/local/bin/yarnpkg
62+
RUN curl -sS https://getcomposer.org/installer | php -- --${COMPOSER_VERSION} --install-dir=/usr/local/bin --filename=composer && \
63+
composer --version

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
echo "NOTE: THIS SCRIPT IS FOR DEBUGGING PURPOSES ONLY."
4+
5+
set -e
6+
7+
docker build --progress plain --build-arg PHP_VERSION=8.2 -t perfcom/node-php-git:8.2-2.2 .
8+
9+
# Run it
10+
#docker run -d --name node-php-git perfcom/node-php-git:8.2-2.2

0 commit comments

Comments
 (0)