sforkowany z mirror/composer-and-node-ci
Refactor to use Matrix and multi-arch NodeJS
rodzic
59d03b0760
commit
4f5472dbee
|
@ -12,8 +12,20 @@ env:
|
|||
jobs:
|
||||
build_latest:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAG: php8
|
||||
strategy:
|
||||
matrix:
|
||||
tag: [php8, php7.1]
|
||||
include:
|
||||
- tag: php8
|
||||
buildArgs: ""
|
||||
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ matrix.tag }}
|
||||
|
||||
- tag: php7.1
|
||||
buildArgs: |
|
||||
PHP_VERSION=7.1
|
||||
DEPLOYER_VERSION=v6.6.0
|
||||
COMPOSER_VERSION=2.2.18
|
||||
tags: ${{ env.IMAGE }}:${{ matrix.tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
@ -25,7 +37,7 @@ jobs:
|
|||
|
||||
- name: Login to Docker Hub
|
||||
id: docker_login
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
@ -38,40 +50,7 @@ jobs:
|
|||
pull: true
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
cache-from: ${{ env.IMAGE }}:${{ env.TAG }}
|
||||
cache-from: ${{ env.IMAGE }}:${{ matrix.tag }}
|
||||
cache-to: type=inline
|
||||
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ env.TAG }}
|
||||
|
||||
|
||||
build_71:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TAG: php7.1
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to Docker Hub
|
||||
id: docker_login
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Build 7.1 and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
pull: true
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
cache-from: ${{ env.IMAGE }}:${{ env.TAG }}
|
||||
cache-to: type=inline
|
||||
build-args: |
|
||||
PHP_VERSION=7.1
|
||||
DEPLOYER_VERSION=v6.6.0
|
||||
COMPOSER_VERSION=2.2.18
|
||||
tags: ${{ env.IMAGE }}:${{ env.TAG }}
|
||||
build-args: ${{ matrix.buildArgs }}
|
||||
tags: ${{ matrix.tags }}
|
||||
|
|
17
Dockerfile
17
Dockerfile
|
@ -73,10 +73,23 @@ RUN \
|
|||
&& chmod +x /usr/local/bin/dep
|
||||
|
||||
|
||||
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
||||
ARG TARGETARCH
|
||||
|
||||
# Install node, npm and yarn
|
||||
ARG NODE_VERSION="v16.17.0"
|
||||
ARG NODE_VERSION="v16.17.1"
|
||||
RUN \
|
||||
curl -L "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.xz" \
|
||||
if [ "${TARGETARCH}" = "amd64" ]; then \
|
||||
ARCHITECTURE=x64; \
|
||||
elif [ "${TARGETARCH}" = "arm" ]; then \
|
||||
ARCHITECTURE=armv7l; \
|
||||
elif [ "${TARGETARCH}" = "arm64" ]; then \
|
||||
ARCHITECTURE=arm64; \
|
||||
else \
|
||||
echo "Unknown TARGETARCH: '${TARGETARCH}'";\
|
||||
exit 1; \
|
||||
fi \
|
||||
&& curl -L "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${ARCHITECTURE}.tar.xz" \
|
||||
--output node.tar.xz \
|
||||
&& tar xJf node.tar.xz -C /usr --strip-components=1 --no-same-owner \
|
||||
&& rm node.tar.xz \
|
||||
|
|
Ładowanie…
Reference in New Issue