Skip to content

Commit

Permalink
feat: PHP+Swoole versions, custom Dockerfile and Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
leocavalcante committed Nov 22, 2023
1 parent 9cda726 commit b73c370
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.hfctl
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
FROM hyperf/hyperf:8.2-alpine-v3.18-swoole-v5.1
RUN apk add php82-pecl-xdebug
ADD php.ini /etc/php82/conf.d/99_hfctl.ini
ARG PHP=8.2
ARG SWOOLE=5.1
FROM hyperf/hyperf:${PHP}-alpine-v3.18-swoole-v${SWOOLE}
ARG PHP=8.2
ENV PHP=$PHP
ADD php.ini /etc/php.ini
RUN apk add php${PHP/./}-pecl-xdebug && \
apk add php${PHP/./}-pecl-pcov -Xhttp://dl-cdn.alpinelinux.org/alpine/edge/community && \
mv /etc/php.ini /etc/php${PHP/./}/conf.d/99_hfctl.ini
28 changes: 23 additions & 5 deletions hfctl
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/usr/bin/env bash

HFCTL=v0.5.0
IMAGE=opencodeco/hfctl:$HFCTL
PHP=8.2
SWOOLE=5.1
HFCID=runtime/hfctl.cid

if [ -f .hfctl ]; then
export $(cat .hfctl | sed 's/#.*//g' | xargs)
fi

IMAGE=${IMAGE:-opencodeco/hfctl:php$PHP-swoole$SWOOLE}

version() {
echo -e "hfctl: \033[1;32m$HFCTL\033[0m"
echo -e "image: \033[1;32m$IMAGE\033[0m"
}

Expand Down Expand Up @@ -130,15 +135,28 @@ analyse() {
}

docker-run() {
docker run --user $UID --rm -w /opt -v ./:/opt $1 --entrypoint $2 $IMAGE ${@:3}
docker run --rm -w /opt -v ./:/opt $1 --entrypoint $2 $IMAGE ${@:3}
}

sonar() {
if [ -z "$SONAR_TOKEN" ]; then
echo -e "\033[0;31mSONAR_TOKEN is not set\033[0m"
exit 1
fi
docker run --rm -v ./:/usr/src -e SONAR_TOKEN="$SONAR_TOKEN" sonarsource/sonar-scanner-cli -Dsonar.branch.name=$(git branch --show-current) $@
}

ps() {
docker ps
}

build() {
docker build -t $IMAGE .
docker build \
--build-arg PHP=$PHP \
--build-arg SWOOLE=$SWOOLE \
--build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \
$@ \
-t $IMAGE .
}

push() {
Expand Down

0 comments on commit b73c370

Please sign in to comment.