diff --git a/.woodpecker/build_release.yml b/.woodpecker/build_release.yml index 320142b..e267237 100644 --- a/.woodpecker/build_release.yml +++ b/.woodpecker/build_release.yml @@ -28,6 +28,12 @@ steps: cron: nightly event: [ cron ] + gen_tags: + image: docker + commands: + - gen-version-list.sh ${CI_COMMIT_TAG} php-${PHP_VERSION} + - cat tags.txt + release_alpine_build_and_publish: image: woodpeckerci/plugin-docker-buildx settings: @@ -36,8 +42,6 @@ steps: from_secret: DOCKERHUB_TOKEN context: ./build repo: vistanarvas/${CI_REPO_NAME} - auto_tag: true - auto_tag_suffix: php-${PHP_VERSION} - default_tag: latest-php-${PHP_VERSION} + tags_file: tags.txt build_args: - BASE_VERSION=${PHP_VERSION} \ No newline at end of file diff --git a/Readme.md b/Readme.md index 5ab01b2..8e394d0 100644 --- a/Readme.md +++ b/Readme.md @@ -1,11 +1,71 @@ # simple-laravel +Get a Laravel server up and running quickly for testing and small-scale deployments with this lightweight Docker image. +This image is designed to provide a hassle-free way to spin up a Laravel server for development, testing, and small-scale production environments. It's perfect for rapid prototyping, proof-of-concepts, and low-traffic web applications. + +Based on the official PHP image, ensuring a stable and secure foundation +Pre-configured with Laravel and its dependencies, saving you time and effort +Optimized for small-scale deployments, keeping resource usage to a minimum +Easy to use and extend, with a simple and intuitive configuration + +## tags +This image follows a similar tagging schema as the official PHP image. +`{simple-laravel version}-php-{php version} (e.g. vistanarvas/simple-laravel:2.0.2-php-8.3)` ## setting laravel up in a container +### compose + +```yaml +version: '3' +services: + app: + image: vistanarvas/simple-laravel + ports: + - '8080:8080' + - '5173:5173' + environment: + DB_CONNECTION: mysql + DB_HOST: mysql + DB_PORT: 3306 + DB_DATABASE: laravel + DB_USERNAME: laravel + DB_PASSWORD: password + + BOOT_COMPOSER_INSTALL: true # runs `composer install` on boot + BOOT_NPM_INSTALL: true # runs `npm install` on boot + BOOT_NPM_DEV: true # starts `npm dev` + + # Extra packages and php extensions to install on first boot + # EXTRA_APK_PACKAGES: # example: libpng-dev icu-dev + # EXTRA_PHP_EXTENSIONS: # example: exif intl bcmath gd pdo_mysql + volumes: + - '[Path to your laravel project]:/var/www/html' + depends_on: + - mysql + + mysql: + image: 'mysql/mysql-server:8.0' + environment: + MYSQL_ROOT_PASSWORD: root_password + MYSQL_ROOT_HOST: '%' + MYSQL_DATABASE: laravel + MYSQL_USER: laravel + MYSQL_PASSWORD: password + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - 'mysql:/var/lib/mysql' + +volumes: + mysql: + driver: local +``` + +## suggested changes to laravel + ### vite -edit `/vite.config.js` +`/vite.config.js` ```diff import laravel from 'laravel-vite-plugin'; @@ -20,9 +80,8 @@ edit `/vite.config.js` input: [ ``` - -edit `/package.json` - +--- +`/package.json` ```diff "private": true, "type": "module", diff --git a/docker-compose.yml b/docker-compose.yml index 9406d14..fb39c0d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,57 +3,40 @@ services: app: image: vistanarvas/simple-laravel ports: - - '8080:80' + - '8080:8080' - '5173:5173' environment: - WEBSERVER_PORT: 80 DB_CONNECTION: mysql DB_HOST: mysql DB_PORT: 3306 DB_DATABASE: laravel DB_USERNAME: laravel DB_PASSWORD: password - BOOT_NPM_DEV: true # also starts `npm dev` - BOOT_NPM_INSTALL: true # runs `npm install` on boot + BOOT_COMPOSER_INSTALL: true # runs `composer install` on boot + BOOT_NPM_INSTALL: true # runs `npm install` on boot + BOOT_NPM_DEV: true # starts `npm dev` # Extra packages and php extensions to install on first boot # EXTRA_APK_PACKAGES: # example: libpng-dev icu-dev # EXTRA_PHP_EXTENSIONS: # example: exif intl bcmath gd pdo_mysql + volumes: + - '[Path to your laravel project]:/var/www/html' depends_on: - mysql - - redis - - mailpit mysql: image: 'mysql/mysql-server:8.0' - ports: - - '3306:3306' environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_ROOT_PASSWORD: root_password MYSQL_ROOT_HOST: '%' - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_DATABASE: laravel + MYSQL_USER: laravel + MYSQL_PASSWORD: password MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: - 'mysql:/var/lib/mysql' - redis: - image: 'redis:alpine' - ports: - - '6379:6379' - volumes: - - 'redis:/data' - - mailpit: - image: 'axllent/mailpit:latest' - ports: - - '1025:1025' - - '8025:8025' - volumes: mysql: - driver: local - redis: - driver: local + driver: local \ No newline at end of file diff --git a/gen-version-list.sh b/gen-version-list.sh new file mode 100755 index 0000000..67612b3 --- /dev/null +++ b/gen-version-list.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# this script generates a tags_file for Buildx (https://woodpecker-ci.org/plugins/Docker%20Buildx) + + +# Check if a command-line argument is provided +if [ -z "$1" ]; then + echo "Please provide a version as a command-line argument." + exit 1 +fi + +# Example v2.0.1 +version=$1 + +# Suffix +[[ -n $2 ]] && suffix="-$2" || suffix="" + +# Check if the first character is "V" or "v" and remove it +if [[ "${version:0:1}" == "V" || "${version:0:1}" == "v" ]]; then + version="${version#?}" +fi + +# Split the version into an array using the "." as a delimiter +IFS='.' read -ra version_array <<< "$version" + +echo "latest$suffix" > tags.txt + +# Iterate through the array and print each element followed by a new line +build_string="" +for i in "${version_array[@]}"; do + build_string="$build_string.$i" + echo "${build_string#?}$suffix" >> tags.txt +done \ No newline at end of file