Skip to content

Commit

Permalink
Add docker frankenPHP cli image
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMellerin authored Dec 2, 2024
1 parent 6ed19f5 commit d43a869
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker image
name: Build Docker CI image

on:
push:
Expand All @@ -14,7 +14,7 @@ env:

jobs:
build-and-push-image:
name: Push Docker image to Docker Hub
name: Push Docker CI image to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -34,7 +34,7 @@ jobs:
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: simonmellerin/db-tools-bundle-ci
images: makinacorpus/db-tools-bundle-ci

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/build-and-publish-franken-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Docker FrankenPHP image

on:
push:
branches:
- "main"
tags:
- '*'
paths:
- .gitattributes
- .github/workflows/build-and-publish-franken-image.yml
- docker/franken-image/Dockerfile
- composer.*
- src/**

env:
IMAGE_NAME: db-tools-bundle

jobs:
build-and-push-image:
name: Push Docker FrankenPHP image to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: makinacorpus/db-tools-bundle

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: docker/franken-image/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags == 'main' && 'unstable' || steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 6 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: "PHPUnit with PHP version matrix"
runs-on: ubuntu-latest
container:
image: simonmellerin/db-tools-bundle-ci:main
image: makinacorpus/db-tools-bundle-ci:main

strategy:
matrix:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
name: "PHPUnit with PostgreSQL"
runs-on: ubuntu-latest
container:
image: simonmellerin/db-tools-bundle-ci:main
image: makinacorpus/db-tools-bundle-ci:main
needs: "phpunit-smoke-tests"

strategy:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
name: "PHPUnit with MariaDB"
runs-on: ubuntu-latest
container:
image: simonmellerin/db-tools-bundle-ci:main
image: makinacorpus/db-tools-bundle-ci:main
needs: "phpunit-smoke-tests"

strategy:
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
name: "PHPUnit with MySQL"
runs-on: ubuntu-latest
container:
image: simonmellerin/db-tools-bundle-ci:main
image: makinacorpus/db-tools-bundle-ci:main
needs: "phpunit-smoke-tests"

strategy:
Expand Down Expand Up @@ -283,7 +283,7 @@ jobs:
# name: "PHPUnit with SQL Server"
# runs-on: ubuntu-latest
# container:
# image: simonmellerin/db-tools-bundle-ci:main
# image: makinacorpus/db-tools-bundle-ci:main
# needs: "phpunit-smoke-tests"

# strategy:
Expand Down Expand Up @@ -346,7 +346,7 @@ jobs:
name: "PHPUnit with SQLite"
runs-on: ubuntu-latest
container:
image: simonmellerin/db-tools-bundle-ci:main
image: makinacorpus/db-tools-bundle-ci:main
needs: "phpunit-smoke-tests"

strategy:
Expand Down
47 changes: 47 additions & 0 deletions docker/franken-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM dunglas/frankenphp:1-php8.3
ARG TAG=dev-main
ARG EXTRA_COMPOSER_REQUIREMENTS=''

# Basic requirements
RUN apt-get update
RUN apt-get install -yqq --no-install-recommends default-mysql-client acl iproute2 zip zlib1g-dev libzip-dev \
libxml2-dev libpng-dev libghc-curl-dev libldb-dev libldap2-dev gnupg2 libpq-dev sqlite3

# Installing postgresql-client-16
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc| gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \
sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
apt-get update && apt-get install -y postgresql-16

# PHP required extensions
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install -j$(nproc) pgsql pdo_pgsql pdo mysqli pdo_mysql zip xml gd curl bcmath
RUN docker-php-ext-enable pdo_pgsql pdo_mysql sodium

# SQL Server support
ENV ACCEPT_EULA=Y
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN apt-get -y --no-install-recommends install msodbcsql18 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv

# Cleanup.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /var/www

RUN composer require \
makinacorpus/db-tools-bundle:$TAG \
symfony/password-hasher:* \
# TODO uncomment these lines when those packages
# will have a compatible version available
# on packagist
# db-tools-bundle/pack-fr-fr:$TAG \
# db-tools-bundle/pack-faker:$TAG \
$EXTRA_COMPOSER_REQUIREMENTS

ENTRYPOINT ["/var/www/vendor/bin/db-tools"]

0 comments on commit d43a869

Please sign in to comment.