Skip to content

Commit

Permalink
ci: add Super-Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Dec 1, 2023
1 parent b675d09 commit e2e50e2
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,4 @@ jobs:
docker buildx imagetools inspect $(jq -cr '.target."${{matrix.target}}-${{matrix.variant}}".tags | first' <<< $METADATA)
env:
METADATA: ${{needs.prepare.outputs.metadata}}

33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint Code Base
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
statuses: write

steps:
-
name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Lint Code Base
uses: super-linter/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
5 changes: 5 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignored:
- DL3006
- DL3008
- DL3018
- DL3022
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ LABEL org.opencontainers.image.vendor="Kévin Dunglas"
FROM common AS builder

ARG FRANKENPHP_VERSION='dev'
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY --from=golang-base /usr/local/go /usr/local/go

Expand All @@ -71,12 +72,11 @@ WORKDIR /go/src/app
COPY --link go.mod go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

RUN mkdir caddy && cd caddy
COPY --link caddy/go.mod caddy/go.sum ./caddy/

RUN cd caddy && \
go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
WORKDIR /go/src/app/caddy
COPY --link caddy/go.mod caddy/go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

WORKDIR /go/src/app
COPY --link *.* ./
COPY --link caddy caddy
COPY --link C-Thread-Pool C-Thread-Pool
Expand All @@ -87,12 +87,14 @@ COPY --link testdata testdata
# see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for PHP values
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS

RUN cd caddy/frankenphp && \
GOBIN=/usr/local/bin go install -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin go install -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
cp Caddyfile /etc/caddy/Caddyfile && \
frankenphp version

WORKDIR /go/src/app


FROM common AS runner

Expand Down
16 changes: 10 additions & 6 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ LABEL org.opencontainers.image.vendor="Kévin Dunglas"
FROM common AS builder

ARG FRANKENPHP_VERSION='dev'
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

COPY --link --from=golang-base /usr/local/go /usr/local/go

ENV PATH /usr/local/go/bin:$PATH

# hadolint ignore=SC2086
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
argon2-dev \
Expand All @@ -67,11 +69,11 @@ WORKDIR /go/src/app
COPY --link go.mod go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

RUN mkdir caddy && cd caddy
COPY caddy/go.mod caddy/go.sum ./caddy/

RUN cd caddy && go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
WORKDIR /go/src/app/caddy
COPY caddy/go.mod caddy/go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

WORKDIR /go/src/app
COPY --link *.* ./
COPY --link caddy caddy
COPY --link C-Thread-Pool C-Thread-Pool
Expand All @@ -82,11 +84,13 @@ COPY --link testdata testdata
# see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for php values
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS

RUN cd caddy/frankenphp && \
GOBIN=/usr/local/bin go install -ldflags "-extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin go install -ldflags "-extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
frankenphp version

WORKDIR /go/src/app


FROM common AS runner

Expand Down
2 changes: 1 addition & 1 deletion build-static.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/sh

set -o errexit
trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -o xtrace

if ! type "git" > /dev/null; then
Expand Down Expand Up @@ -72,6 +71,7 @@ fi

./bin/spc doctor
./bin/spc fetch --with-php="$PHP_VERSION" --for-extensions="$PHP_EXTENSIONS"
# shellcheck disable=SC2086
./bin/spc build --enable-zts --build-embed $extraOpts "$PHP_EXTENSIONS" --with-libs="$PHP_EXTENSION_LIBS"
CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $(./buildroot/bin/php-config --includes | sed s#-I/#-I"$PWD"/buildroot/#g)"
export CGO_CFLAGS
Expand Down
15 changes: 8 additions & 7 deletions dev-alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ RUN apk add --no-cache \
libtool && \
echo 'set auto-load safe-path /' > /root/.gdbinit

RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git && \
cd php-src && \
WORKDIR /usr/local/src/php
RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git . && \
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
./buildconf --force && \
./configure \
Expand All @@ -47,18 +47,19 @@ RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git && \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--enable-debug && \
make -j$(nproc) && \
make -j"$(nproc)" && \
make install && \
ldconfig /etc/ld.so.conf.d && \
cp php.ini-development /usr/local/lib/php.ini && \
echo -e "zend_extension=opcache.so\nopcache.enable=1" >> /usr/local/lib/php.ini &&\
echo "zend_extension=opcache.so" >> /usr/local/lib/php.ini && \
echo "opcache.enable=1" >> /usr/local/lib/php.ini && \
php --version

WORKDIR /go/src/app

COPY . .

RUN cd caddy/frankenphp && \
go build
WORKDIR /go/src/app/caddy/frankenphp
RUN go build

WORKDIR /go/src/app
CMD [ "zsh" ]
16 changes: 9 additions & 7 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV PHPIZE_DEPS \
pkg-config \
re2c

# hadolint ignore=DL3009
RUN apt-get update && \
apt-get -y --no-install-recommends install \
$PHPIZE_DEPS \
Expand Down Expand Up @@ -41,8 +42,8 @@ RUN apt-get update && \
&& \
apt-get clean

RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git && \
cd php-src && \
WORKDIR /usr/local/src/php
RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git . && \
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
./buildconf --force && \
./configure \
Expand All @@ -51,18 +52,19 @@ RUN git clone --branch=PHP-8.3 https://github.com/php/php-src.git && \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--enable-debug && \
make -j$(nproc) && \
make -j"$(nproc)" && \
make install && \
ldconfig && \
cp php.ini-development /usr/local/lib/php.ini && \
echo "zend_extension=opcache.so\nopcache.enable=1" >> /usr/local/lib/php.ini &&\
echo "zend_extension=opcache.so" >> /usr/local/lib/php.ini && \
echo "opcache.enable=1" >> /usr/local/lib/php.ini && \
php --version

WORKDIR /go/src/app

COPY . .

RUN cd caddy/frankenphp && \
go build
WORKDIR /go/src/app/caddy/frankenphp
RUN go build

WORKDIR /go/src/app
CMD [ "zsh" ]
10 changes: 5 additions & 5 deletions static-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG FRANKENPHP_VERSION=''
ARG PHP_VERSION=''
ARG PHP_EXTENSIONS=''
ARG PHP_EXTENSION_LIBS=''
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk update; \
apk add --no-cache \
Expand Down Expand Up @@ -56,15 +57,14 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"
COPY --from=composer/composer:2-bin --link /composer /usr/bin/composer

WORKDIR /go/src/app

COPY go.mod go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

RUN mkdir caddy && cd caddy
COPY caddy/go.mod caddy/go.sum ./caddy/

RUN cd caddy && go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
WORKDIR /go/src/app/caddy
COPY caddy/go.mod caddy/go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

WORKDIR /go/src/app
COPY *.* ./
COPY caddy caddy
COPY C-Thread-Pool C-Thread-Pool
Expand Down

0 comments on commit e2e50e2

Please sign in to comment.