Use hadolint to check dockerfile
This commit is contained in:
parent
f464553da4
commit
8b82b74f52
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -5,6 +5,17 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Docker Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Lint Dockerfile
|
||||||
|
uses: hadolint/hadolint-action@master
|
||||||
|
with:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ignore: DL3007,DL3018 # Ignore using latest on mlocati/php-extension-installer & version in apk add
|
||||||
build:
|
build:
|
||||||
name: Docker build
|
name: Docker build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
33
Dockerfile
33
Dockerfile
@ -4,6 +4,20 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
|
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
|
||||||
# https://docs.docker.com/compose/compose-file/#target
|
# https://docs.docker.com/compose/compose-file/#target
|
||||||
|
|
||||||
|
# Builder images
|
||||||
|
FROM composer/composer:2-bin AS composer
|
||||||
|
|
||||||
|
FROM mlocati/php-extension-installer:latest AS php_extension_installer
|
||||||
|
|
||||||
|
# Build Caddy with the Mercure and Vulcain modules
|
||||||
|
FROM caddy:2.6-builder-alpine AS app_caddy_builder
|
||||||
|
|
||||||
|
RUN xcaddy build \
|
||||||
|
--with github.com/dunglas/mercure \
|
||||||
|
--with github.com/dunglas/mercure/caddy \
|
||||||
|
--with github.com/dunglas/vulcain \
|
||||||
|
--with github.com/dunglas/vulcain/caddy
|
||||||
|
|
||||||
# Prod image
|
# Prod image
|
||||||
FROM php:8.2-fpm-alpine AS app_php
|
FROM php:8.2-fpm-alpine AS app_php
|
||||||
|
|
||||||
@ -20,7 +34,7 @@ ENV APP_ENV=prod
|
|||||||
WORKDIR /srv/app
|
WORKDIR /srv/app
|
||||||
|
|
||||||
# php extensions installer: https://github.com/mlocati/docker-php-extension-installer
|
# php extensions installer: https://github.com/mlocati/docker-php-extension-installer
|
||||||
COPY --from=mlocati/php-extension-installer --link /usr/bin/install-php-extensions /usr/local/bin/
|
COPY --from=php_extension_installer --link /usr/bin/install-php-extensions /usr/local/bin/
|
||||||
|
|
||||||
# persistent / runtime deps
|
# persistent / runtime deps
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
@ -64,10 +78,10 @@ CMD ["php-fpm"]
|
|||||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
ENV PATH="${PATH}:/root/.composer/vendor/bin"
|
ENV PATH="${PATH}:/root/.composer/vendor/bin"
|
||||||
|
|
||||||
COPY --from=composer/composer:2-bin --link /composer /usr/bin/composer
|
COPY --from=composer --link /composer /usr/bin/composer
|
||||||
|
|
||||||
# prevent the reinstallation of vendors at every changes in the source code
|
# prevent the reinstallation of vendors at every changes in the source code
|
||||||
COPY composer.* symfony.* ./
|
COPY --link composer.* symfony.* ./
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
if [ -f composer.json ]; then \
|
if [ -f composer.json ]; then \
|
||||||
composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress; \
|
composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress; \
|
||||||
@ -75,7 +89,7 @@ RUN set -eux; \
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# copy sources
|
# copy sources
|
||||||
COPY --link . .
|
COPY --link . ./
|
||||||
RUN rm -Rf docker/
|
RUN rm -Rf docker/
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
@ -93,7 +107,7 @@ FROM app_php AS app_php_dev
|
|||||||
ENV APP_ENV=dev XDEBUG_MODE=off
|
ENV APP_ENV=dev XDEBUG_MODE=off
|
||||||
VOLUME /srv/app/var/
|
VOLUME /srv/app/var/
|
||||||
|
|
||||||
RUN rm $PHP_INI_DIR/conf.d/app.prod.ini; \
|
RUN rm "$PHP_INI_DIR/conf.d/app.prod.ini"; \
|
||||||
mv "$PHP_INI_DIR/php.ini" "$PHP_INI_DIR/php.ini-production"; \
|
mv "$PHP_INI_DIR/php.ini" "$PHP_INI_DIR/php.ini-production"; \
|
||||||
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
|
||||||
|
|
||||||
@ -104,15 +118,6 @@ RUN set -eux; \
|
|||||||
|
|
||||||
RUN rm -f .env.local.php
|
RUN rm -f .env.local.php
|
||||||
|
|
||||||
# Build Caddy with the Mercure and Vulcain modules
|
|
||||||
FROM caddy:2.6-builder-alpine AS app_caddy_builder
|
|
||||||
|
|
||||||
RUN xcaddy build \
|
|
||||||
--with github.com/dunglas/mercure \
|
|
||||||
--with github.com/dunglas/mercure/caddy \
|
|
||||||
--with github.com/dunglas/vulcain \
|
|
||||||
--with github.com/dunglas/vulcain/caddy
|
|
||||||
|
|
||||||
# Caddy image
|
# Caddy image
|
||||||
FROM caddy:2.6-alpine AS app_caddy
|
FROM caddy:2.6-alpine AS app_caddy
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user