diff --git a/.woodpecker/build_alpine.yml b/.woodpecker/build_alpine.yml deleted file mode 100644 index 8ef7163..0000000 --- a/.woodpecker/build_alpine.yml +++ /dev/null @@ -1,37 +0,0 @@ -when: - path: - include: [ '.woodpecker/build_alpine.yml', 'build/*', 'Dockerfile_alpine' ] - cron: nightly - event: [ cron, release, push, manual ] - -steps: - cron_pre_check: - image: docker - commands: - - docker pull php:8-fpm-alpine - - docker pull vistanarvas/simple-laravel:dev-alpine - - BASE_IMG=$(docker inspect php:8-fpm-alpine --format='{{.Created}}' | cut -d '.' -f 1) - - PREV_IMG=$(docker inspect vistanarvas/simple-laravel:dev-alpine --format='{{.Created}}' | cut -d '.' -f 1) - - BASE_DATE=$(date -D "%Y-%m-%dT%H:%M:%S" -d "$BASE_IMG" +%s) - - PREV_DATE=$(date -D "%Y-%m-%dT%H:%M:%S" -d "$PREV_IMG" +%s) - - if [ "$PREV_DATE" -gt "$BASE_DATE" ]; then exit 1; fi - volumes: - - /var/run/docker.sock:/var/run/docker.sock - -# dev_alpine_build_and_publish: -# image: woodpeckerci/plugin-docker-buildx -# settings: -# username: vistanarvas -# password: -# from_secret: DOCKERHUB_TOKEN -# context: ./build -# repo: vistanarvas/${CI_REPO_NAME} -# tag: ${CI_COMMIT_BRANCH}-alpine -# dockerfile: Dockerfile_alpine -# when: -# evaluate: '! test -f SKIP_BUILD' -# branch: -# exclude: [ main, master ] -# path: -# include: [ '.woodpecker/build_alpine.yml', 'build/*', 'Dockerfile_alpine' ] -# event: [ push, manual ] \ No newline at end of file diff --git a/.woodpecker/build_dev.yml b/.woodpecker/build_dev.yml new file mode 100644 index 0000000..53ee139 --- /dev/null +++ b/.woodpecker/build_dev.yml @@ -0,0 +1,25 @@ +matrix: + PHP_VERSION: + - latest + +when: + branch: + exclude: [ main, master ] + path: + include: [ '.woodpecker/build_dev.yml', 'build/*', 'Dockerfile' ] + cron: nightly + event: [ push, manual ] + +steps: + dev_alpine_build_and_publish: + image: woodpeckerci/plugin-docker-buildx + settings: + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN + context: ./build + repo: vistanarvas/${CI_REPO_NAME} + tag: ${CI_COMMIT_BRANCH}-${PHP_VERSION} + dockerfile: Dockerfile_alpine + build_args: + PHP_VERSION: ${PHP_VERSION} \ No newline at end of file diff --git a/.woodpecker/build_release.yml b/.woodpecker/build_release.yml new file mode 100644 index 0000000..f519f9f --- /dev/null +++ b/.woodpecker/build_release.yml @@ -0,0 +1,41 @@ +matrix: + PHP_VERSION: + - latest + - 8-fpm-alpine + - 8.3-fpm-alpine + - 8.2-fpm-alpine + - 8.1-fpm-alpine + +when: + branch: + include: [ main, master ] + cron: nightly + event: [ cron, release, manual ] + +steps: + cron_pre_check: + image: docker + commands: + - docker pull php:${PHP_VERSION} + - docker pull vistanarvas/simple-laravel:${PHP_VERSION} + - BASE_IMG=$(docker inspect php:${PHP_VERSION} --format='{{.Created}}' | cut -d '.' -f 1) + - PREV_IMG=$(docker inspect vistanarvas/simple-laravel:${PHP_VERSION} --format='{{.Created}}' | cut -d '.' -f 1) + - BASE_DATE=$(date -D "%Y-%m-%dT%H:%M:%S" -d "$BASE_IMG" +%s) + - PREV_DATE=$(date -D "%Y-%m-%dT%H:%M:%S" -d "$PREV_IMG" +%s) + - if [ "$PREV_DATE" -gt "$BASE_DATE" ]; then echo "no rebuild needed"; exit 1; fi + volumes: + - /var/run/docker.sock:/var/run/docker.sock + when: + cron: nightly + event: [ cron ] + + release_alpine_build_and_publish: + image: woodpeckerci/plugin-docker-buildx + settings: + username: vistanarvas + password: + from_secret: DOCKERHUB_TOKEN + context: ./build + repo: vistanarvas/${CI_REPO_NAME} + tag: ${PHP_VERSION} + dockerfile: Dockerfile_alpine \ No newline at end of file diff --git a/.woodpecker/build_ubuntu.yml b/.woodpecker/build_ubuntu.yml deleted file mode 100644 index c2ce248..0000000 --- a/.woodpecker/build_ubuntu.yml +++ /dev/null @@ -1,57 +0,0 @@ -when: - path: - include: [ '.woodpecker/build_ubuntu.yml', 'build/*', 'Dockerfile_ubuntu' ] - cron: nightly - event: [ cron, release, push, manual ] - -steps: - release_ubuntu_build_and_publish: - image: woodpeckerci/plugin-docker-buildx - settings: - username: vistanarvas - password: - from_secret: DOCKERHUB_TOKEN - context: ./build - repo: vistanarvas/${CI_REPO_NAME} - auto_tag: true - default_suffix: -ubuntu - dockerfile: Dockerfile_ubuntu - when: - branch: - include: [ main, master ] - event: release - - cron_ubuntu_build_and_publish: - image: woodpeckerci/plugin-docker-buildx - settings: - username: vistanarvas - password: - from_secret: DOCKERHUB_TOKEN - context: ./build - repo: vistanarvas/${CI_REPO_NAME} - tag: nightly-ubuntu - dockerfile: Dockerfile_ubuntu - when: - branch: - include: [ main, master ] - path: - include: [ '.woodpecker/build_ubuntu.yml', 'build/*', 'Dockerfile_ubuntu' ] - cron: nightly - event: [ cron ] - - dev_ubuntu_build_and_publish: - image: woodpeckerci/plugin-docker-buildx - settings: - username: vistanarvas - password: - from_secret: DOCKERHUB_TOKEN - context: ./build - repo: vistanarvas/${CI_REPO_NAME} - tag: ${CI_COMMIT_BRANCH}-ubuntu - dockerfile: Dockerfile_ubuntu - when: - branch: - exclude: [ main, master ] - path: - include: [ '.woodpecker/build_ubuntu.yml', 'build/*', 'Dockerfile_ubuntu' ] - event: [ push, manual ] \ No newline at end of file diff --git a/Dockerfile_alpine b/Dockerfile similarity index 91% rename from Dockerfile_alpine rename to Dockerfile index 92a0b03..0f1fc30 100644 --- a/Dockerfile_alpine +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM php:8-fpm-alpine +ARG PHP_VERSION + +FROM php:$PHP_VERSION ENV NVM_DIR="/root/.nvm" diff --git a/Dockerfile_ubuntu b/Dockerfile_ubuntu deleted file mode 100644 index ba24d90..0000000 --- a/Dockerfile_ubuntu +++ /dev/null @@ -1,42 +0,0 @@ -FROM ubuntu:latest - -# node version number like "12.22.1" or empty for the latest version -ARG NODE_VERSION='' - -# composer version number like "2.1" or empty for the latest version -ARG COMPOSER_VERSION='' - -# disables asking for input -ARG DEBIAN_FRONTEND="noninteractive" - -ENV NVM_DIR="/root/.nvm" - -# port to for the webserver -ENV WEBSERVER_PORT=8080 - -COPY start-container.sh /usr/local/bin/start-container - -RUN apt-get -y update \ - && apt-get install -y curl git 7zip php php-xml php-curl php-xml php-mbstring php-mysql php-gd php-zip php-bcmath php-intl \ - && apt-get clean \ - && chmod +x /usr/local/bin/start-container \ - && echo "install composer" \ - && curl -o composer-setup.php https://getcomposer.org/installer \ - && curl -o composer-setup.sig https://composer.github.io/installer.sig \ - && echo " composer-setup.php" >> composer-setup.sig \ - && sha384sum -c composer-setup.sig \ - && if [ -n "$COMPOSER_VERSION" ]; then COMPOSER_VERSION="--${COMPOSER_VERSION}"; fi \ - && php composer-setup.php --install-dir=/usr/local/bin --filename=composer $COMPOSER_VERSION \ - && rm composer-setup.php composer-setup.sig /var/www/html/* \ - && echo "install nvm and node" \ - && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash \ - && if [ -z "$NODE_VERSION" ]; then NODE_VERSION="node"; fi \ - && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \ - && nvm install $NODE_VERSION \ - && nvm alias default $NODE_VERSION; - -EXPOSE ${WEBSERVER_PORT} - -WORKDIR /var/www/html - -ENTRYPOINT ["start-container"] \ No newline at end of file diff --git a/build/start-container.sh b/build/start-container.sh index ce773fb..e7abf6d 100644 --- a/build/start-container.sh +++ b/build/start-container.sh @@ -3,9 +3,6 @@ # exit when any command fails set -e -# init nvm -\. "$NVM_DIR"/nvm.sh - if [[ "$BOOT_NPM_INSTALL" = true ]]; then echo "npm install" npm install