diff --git a/.dockerignore b/.dockerignore index e91689fa..95fb3c5d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ README.md LICENCE .git docker-compose.yml +Dockerfile +.github diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 11efd8d8..aa4dcbcf 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -10,17 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up CI Image Metadata id: docker_meta_ci - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v5 with: images: solidnerd/bookstack-dev - tag-sha: true + tags: | + type=sha + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Build Image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile @@ -31,44 +35,53 @@ jobs: labels: ${{ steps.docker_meta_ci.outputs.labels }} cache-from: type=registry,ref=solidnerd/bookstack-dev:master outputs: type=docker,dest=/tmp/image-bookstack.tar + - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: image-bookstack-master path: /tmp/image-bookstack.tar if-no-files-found: warn + e2e: runs-on: ubuntu-latest needs: build steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: image-bookstack-master path: /tmp + - name: Load Docker image run: | docker load --input /tmp/image-bookstack.tar docker image ls -a + push: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 needs: e2e steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up Docker Hub Image Metadata id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v5 with: images: solidnerd/bookstack,ghcr.io/solidnerd/docker-bookstack - tag-semver: | - {{version}} - {{major}}.{{minor}} - {{major}}.{{minor}}.{{patch}} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}}.{{minor}}.{{patch}} + # Get "master" for master-branch changes + type=ref,event=branch + - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: image-bookstack-master path: /tmp @@ -77,24 +90,29 @@ jobs: run: | docker load --input /tmp/image-bookstack.tar docker image ls -a + - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.CR_PAT }} + - name: Build and Push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fff73aa4..d1bf1e42 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,17 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Docker meta ci id: docker_meta_ci - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v5 with: images: solidnerd/bookstack-dev - tag-sha: true + tags: | + type=sha + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Build and push Dev - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile @@ -32,27 +36,32 @@ jobs: cache-from: type=registry,ref=solidnerd/bookstack-dev:master cache-to: type=inline outputs: type=docker,dest=/tmp/image-bookstack.tar + - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: image-bookstack path: /tmp/image-bookstack.tar if-no-files-found: warn + e2e: runs-on: ubuntu-latest needs: build steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: image-bookstack path: /tmp if-no-files-found: warn + - name: Load Docker image run: | docker load --input /tmp/image-bookstack.tar docker image ls -a + - name: Execute End-to-End Test run: make e2e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71734384..c0f69e6b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,24 +3,28 @@ on: push: # Sequence of patterns matched against refs/tags tags: - - '*' # Push events to matching v*, i.e. v1.0, v0.4.4 + - '*' # Push on all tag events jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up CI Image Metadata id: docker_meta_ci - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v5 with: images: solidnerd/bookstack-dev - tag-sha: true + tags: | + type=sha + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Build and push Dev - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile @@ -31,68 +35,90 @@ jobs: labels: ${{ steps.docker_meta_ci.outputs.labels }} cache-from: type=registry,ref=solidnerd/bookstack-dev:master outputs: type=docker,dest=/tmp/image-bookstack.tar + - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: image-bookstack-master path: /tmp/image-bookstack.tar + e2e: runs-on: ubuntu-latest needs: build steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: image-bookstack-master path: /tmp + - name: Load Docker image run: | docker load --input /tmp/image-bookstack.tar docker image ls -a + push: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 needs: e2e steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Set up Docker Hub Image Metadata id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v5 with: - images: solidnerd/bookstack,ghcr.io/solidnerd/docker-bookstack - tag-semver: | - {{version}} - {{major}}.{{minor}} - {{major}}.{{minor}}.{{patch}} + images: | + solidnerd/bookstack + ghcr.io/solidnerd/docker-bookstack + # Blanket-enable "latest" tagging for all of the releases that make it + # this far, as SemVer's pre-release tag is used as a build indicator + # for this project. Note that _actual_ semver build info is not used, + # as it is discarded by almost everything that consumes SemVer (as it + # should be). + flavor: | + latest=true + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}}.{{minor}}.{{patch}} + - name: Download artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: image-bookstack-master path: /tmp + - name: Load Docker image run: | docker load --input /tmp/image-bookstack.tar docker image ls -a + - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.CR_PAT }} + - name: Build and Push master - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile @@ -103,26 +129,27 @@ jobs: labels: ${{ steps.docker_meta.outputs.labels }} cache-from: type=registry,ref=solidnerd/bookstack-dev:${{ github.sha }} cache-to: type=registry,ref=solidnerd/bookstack-dev:${{ github.sha }} + create-release: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 needs: push steps: # To use this repository's private action, you must check out the repository - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Generate changelog id: changelog - uses: metcalfc/changelog-generator@v0.4.4 + uses: metcalfc/changelog-generator@v4.6.2 with: myToken: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release id: create_release - uses: actions/create-release@v1.1.4 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} body: ${{ steps.changelog.outputs.changelog }} draft: false prerelease: false diff --git a/Dockerfile b/Dockerfile index 21938e7d..23fbde4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ -FROM alpine:3 as bookstack -ENV BOOKSTACK_VERSION=21.05.2 +FROM alpine:3 AS bookstack +ENV BOOKSTACK_VERSION=v25.05 RUN apk add --no-cache curl tar RUN set -x; \ - curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \ + curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/${BOOKSTACK_VERSION}.tar.gz \ && mkdir -p /bookstack \ && tar xvf bookstack.tar.gz -C /bookstack --strip-components=1 \ && rm bookstack.tar.gz -FROM php:7.4-apache-buster as final +FROM php:8.4-apache-bookworm AS final RUN set -x; \ apt-get update \ && apt-get install -y --no-install-recommends \ @@ -22,17 +22,16 @@ RUN set -x; \ libxml2-dev \ fontconfig \ fonts-freefont-ttf \ - wkhtmltopdf \ + wget \ tar \ curl \ libzip-dev \ unzip \ - \ - && docker-php-ext-install -j$(nproc) dom pdo pdo_mysql zip tidy \ - && docker-php-ext-configure ldap \ - && docker-php-ext-install -j$(nproc) ldap \ - && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ - && docker-php-ext-install -j$(nproc) gd + && docker-php-ext-install -j$(nproc) dom pdo pdo_mysql zip tidy \ + && docker-php-ext-configure ldap \ + && docker-php-ext-install -j$(nproc) ldap \ + && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd RUN a2enmod rewrite remoteip; \ { \ @@ -51,13 +50,11 @@ COPY bookstack.conf /etc/apache2/sites-available/000-default.conf COPY --from=bookstack --chown=33:33 /bookstack/ /var/www/bookstack/ -ARG COMPOSER_VERSION=1.10.16 +ARG COMPOSER_VERSION=2.7.6 RUN set -x; \ cd /var/www/bookstack \ && curl -sS https://getcomposer.org/installer | php -- --version=$COMPOSER_VERSION \ - && /var/www/bookstack/composer.phar global -v require hirak/prestissimo \ && /var/www/bookstack/composer.phar install -v -d /var/www/bookstack/ \ - && /var/www/bookstack/composer.phar global -v remove hirak/prestissimo \ && rm -rf /var/www/bookstack/composer.phar /root/.composer \ && chown -R www-data:www-data /var/www/bookstack diff --git a/Makefile b/Makefile index 04f6ff2a..ded68cbf 100644 --- a/Makefile +++ b/Makefile @@ -13,13 +13,13 @@ build: -t $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE_DEV):$(DOCKER_INTERNAL_TAG) \ --build-arg VCS_REF=$(DOCKER_INTERNAL_TAG) \ --build-arg BUILD_DATE=$(BUILD_DATE) \ - --build-arg VCS_URL=$(VCS_URL) + --build-arg VCS_URL=$(VCS_URL) push-dev: docker push $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE_DEV):$(DOCKER_INTERNAL_TAG) pull: - docker pull $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE_DEV):$(DOCKER_INTERNAL_TAG) + docker pull $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE_DEV):$(DOCKER_INTERNAL_TAG) release: docker tag $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE_DEV):$(DOCKER_INTERNAL_TAG) $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE):$(DOCKER_RELEASE_TAG) @@ -30,8 +30,8 @@ push-release: docker push $(DOCKER_RELEASE_REG)/$(DOCKER_IMAGE):latest -e2e: - @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker-compose -f docker-compose.test.yml up -d - @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker-compose -f docker-compose.test.yml run --rm sut - @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker-compose -f docker-compose.test.yml down -v +e2e: + @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker compose -f docker-compose.test.yml up -d + @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker compose -f docker-compose.test.yml run --rm sut + @BOOKSTACK_IMAGE="$(DOCKER_RELEASE_REG)/${DOCKER_IMAGE_DEV}:${DOCKER_INTERNAL_TAG}" docker compose -f docker-compose.test.yml down -v diff --git a/README.md b/README.md index b7e441e9..ce2473f8 100644 --- a/README.md +++ b/README.md @@ -1,103 +1,117 @@ -## Docker Image For [BookStack](https://github.com/ssddanbrown/BookStack) +# Docker Image For [BookStack](https://github.com/ssddanbrown/BookStack) -[![Build Status](https://travis-ci.org/solidnerd/docker-bookstack.svg?branch=master)](https://travis-ci.org/solidnerd/docker-bookstack) [![](https://images.microbadger.com/badges/image/solidnerd/bookstack.svg)](https://microbadger.com/images/solidnerd/bookstack "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/commit/solidnerd/bookstack.svg)](https://microbadger.com/images/solidnerd/bookstack "Get your own commit badge on microbadger.com") [![](https://images.microbadger.com/badges/version/solidnerd/bookstack.svg)](https://microbadger.com/images/solidnerd/bookstack "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/license/solidnerd/bookstack.svg)](https://microbadger.com/images/solidnerd/bookstack "Get your own license badge on microbadger.com") +![Build Status](https://img.shields.io/github/actions/workflow/status/solidnerd/docker-bookstack/master.yml) +![Latest release](https://img.shields.io/github/v/tag/solidnerd/docker-bookstack?label=Latest%20release) +![GitHub contributors](https://img.shields.io/github/contributors/solidnerd/docker-bookstack) -## Current Version: [21.05.2](https://github.com/SolidNerd/docker-bookstack/blob/master/Dockerfile) +## Changes -### Changes +Users of version 24.2.3 should switch to 24.2.3-1 (or higher); a maintainer +erroneously set image tag 24.2.3 to use 23.2.3 as the release. -In 0.28.0 we changed the container http port from 80 to 8080 to allow root privileges to be dropped -In 0.12.2 we removed `DB_PORT` . You can now specify the port via `DB_HOST` like `DB_HOST=mysql:3306` +Versions higher than 23.6.2 no longer use an in-container `.env` file for +environment variable management. Instead, the preferred approach is to manage +them directly with the container runtime (e.g. Docker's `-e`). This is to +simplify troubleshooting if and when errors occur. The most important change is +that `${APP_KEY}` is no longer provided for you, instead it is up to the +operator to ensure this value is present. Versions prior to this supplied +`${APP_KEY}` (with a default of `SomeRandomStringWith32Characters`. A full +reference of available environment variables is available in the [Bookstack +repository](https://github.com/BookStackApp/BookStack/blob/development/.env.example.complete) -### Quickstart +The version 23.6.0 is broken due to a bad `.env` configuration created by the +entrypoint script. This is fixed in version 23.6.0-1. + +In 0.28.0 we changed the container http port from 80 to 8080 to allow root +privileges to be dropped + +In 0.12.2 we removed `DB_PORT` . You can now specify the port via `DB_HOST` like +`DB_HOST=mysql:3306` + +## Quickstart With Docker Compose is a Quickstart very easy. Run the following command: -``` -docker-compose up +```bash +docker compose up ``` -and after that open your Browser and go to [http://localhost:8080](http://localhost:8080) . You can login with username 'admin@admin.com' and password 'password'. +and after that open your Browser and go to +[http://localhost:8080](http://localhost:8080) . You can login with username +`admin@admin.com` and password `password`. -### Issues +## Issues If you have any issues feel free to create an [issue on GitHub](https://github.com/solidnerd/docker-bookstack/issues). - -### How to use the Image without Docker compose +## How to use the Image without Docker compose Note that if you want to use LDAP, `$` has to be escape like `\$`, i.e. `-e "LDAP_USER_FILTER"="(&(uid=\${user}))"` -Networking changed in Docker v1.9, so you need to do one of the following steps. - -#### Docker < v1.9 - -1. MySQL Container: - -```bash -docker run -d \ --p 3306:3306 \ --e MYSQL_ROOT_PASSWORD=secret \ --e MYSQL_DATABASE=bookstack \ --e MYSQL_USER=bookstack \ --e MYSQL_PASSWORD=secret \ ---name bookstack_db \ -mysql:5.7.21 -``` -2. BookStack Container: - -```bash -docker run -d --link bookstack_db_:mysql \ --p 8080:8080 \ ---name bookstack_21.05.2 \ -solidnerd/bookstack:21.05.2 -``` - -#### Docker 1.9+ +### Docker 1.9+ 1. Create a shared network: -```bash -docker network create bookstack_nw -``` + ```bash + docker network create bookstack_nw + ``` 2. Run MySQL container : -```bash -docker run -d --net bookstack_nw \ --e MYSQL_ROOT_PASSWORD=secret \ --e MYSQL_DATABASE=bookstack \ --e MYSQL_USER=bookstack \ --e MYSQL_PASSWORD=secret \ - --name="bookstack_db" \ - mysql:5.7.21 -``` + ```bash + docker run -d --net bookstack_nw \ + -e MYSQL_ROOT_PASSWORD=secret \ + -e MYSQL_DATABASE=bookstack \ + -e MYSQL_USER=bookstack \ + -e MYSQL_PASSWORD=secret \ + --name="bookstack_db" \ + mysql:9.2.0 + ``` 3. Run BookStack Container -```bash -docker run -d --net bookstack_nw \ --e DB_HOST=bookstack_db:3306 \ --e DB_DATABASE=bookstack \ --e DB_USERNAME=bookstack \ --e DB_PASSWORD=secret \ --p 8080:8080 \ ---name="bookstack_21.05.2" \ - solidnerd/bookstack:21.05.2 -``` - -#### Volumes -To access your `.env` file and important bookstack folders on your host system change `` in the following line to your host directory and add it then to your run command: + ```bash + docker run -d --net bookstack_nw \ + -e DB_HOST=bookstack_db:3306 \ + -e DB_DATABASE=bookstack \ + -e DB_USERNAME=bookstack \ + -e DB_PASSWORD=secret \ + -e APP_URL=http://localhost:8080 \ + -e APP_KEY=SomeRandomStringWith32Characters \ + -p 8080:8080 \ + --name="bookstack_25.5.0" \ + solidnerd/bookstack:25.5.0 + ``` + + The APP_URL parameter should be the base URL for your BookStack instance without + a trailing slash, but including any port numbers. For example: + + `APP_URL=http://example.com` or `APP_URL=http://localhost:8080`. + + The following environment variables are required for Bookstack to start: + - `APP_KEY` + - `APP_URL` + - `DB_HOST` (in the form `${hostname_or_ip_address}:${port}`) + - `DB_DATABASE` + - `DB_USERNAME` + - `DB_PASSWORD` + +### Volumes + +To access your important bookstack folders on your host system change `` +in the following line to your host directory and add it then to your run +command: ```bash ---mount type=bind,source=/.env,target=/var/www/bookstack/.env \ -v :/var/www/bookstack/public/uploads \ -v :/var/www/bookstack/storage/uploads ``` -In case of a windows host machine the .env file has to be already created in the host directory otherwise a folder named .env will be created. -After these steps you can visit [http://localhost:8080](http://localhost:8080) . You can login with username 'admin@admin.com' and password 'password'. +After these steps you can visit [http://localhost:8080](http://localhost:8080). +You can login with username `admin@admin.com` and password `password`. -### Inspiration +## Inspiration -This is a fork of [Kilhog/docker-bookstack](https://github.com/Kilhog/docker-bookstack). Kilhog did the intial work, but I want to go in a different direction. +This is a fork of +[Kilhog/docker-bookstack](https://github.com/Kilhog/docker-bookstack). Kilhog +did the intial work, but I want to go in a different direction. diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..0db7ced4 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,38 @@ +# Making a release + +When the version changes, a new release should be cut. To do this, push a tag +with the [valid SemVer][semver-checker] version number as the tag. +It may also be useful to update documentation references at the same time. + +## Scripts + +Update the Dockerfile with: + +```shell +$ scripts/update_dockerfile.sh +Fetching latest Bookstack release from GitHub API + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 3467 100 3467 0 0 18743 0 --:--:-- --:--:-- --:--:-- 18842 +Found latest version: v24.10.1 +Updating Dockerfile.. +``` + +## Example + +For Bookstack version 23.01: + +```shell +sed -i '' -e 's/22.11.1/23.1.0/g' Dockerfile # 22.11.1 was the previous version +git commit -am "feat: Update Bookstack to version 23.1.0" [-S] +# Build and test this +git tag [-s] -a 23.1.0 -m "Release version 23.01" +git push --tags +sed -i '' -e 's/22.11.1/23.1.0/g' * # Update documentation to point to the +newer release +git commit -am "doc: update references to version 23.1" +``` + +The workflow will then build, test, push, and release this image. + +[semver-checker]: https://jubianchi.github.io/semver-check/ diff --git a/VERSION b/VERSION index e03e87b9..722c6899 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -21.05.2 +25.5.0 diff --git a/docker-compose.test.yml b/docker-compose.test.yml index baa448fd..7caf048f 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -6,7 +6,7 @@ services: depends_on: - bookstack mysql: - image: mysql:5.7.33 + image: mysql:9.2 environment: - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=bookstack @@ -20,6 +20,8 @@ services: depends_on: - mysql environment: + - APP_URL=http://localhost:${DEV_PORT:-8080} + - APP_KEY=SomeRandomStringWith32Characters - DB_HOST=mysql:3306 - DB_DATABASE=bookstack - DB_USERNAME=bookstack diff --git a/docker-compose.yml b/docker-compose.yml index d48cd9a8..ddae8637 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: mysql: - image: mysql:5.7.33 + image: mysql:9.2 environment: - MYSQL_ROOT_PASSWORD=secret - MYSQL_DATABASE=bookstack @@ -11,7 +11,7 @@ services: - mysql-data:/var/lib/mysql bookstack: - image: solidnerd/bookstack:21.05.2 + image: solidnerd/bookstack:25.5.0 depends_on: - mysql environment: @@ -19,6 +19,16 @@ services: - DB_DATABASE=bookstack - DB_USERNAME=bookstack - DB_PASSWORD=secret + # Set the APP_ to the URL of bookstack without without a trailing slash, + # but including any port numbers. For example, one of: + # APP_URL=https://example.com + # APP_URL=http://localhost:8080 + # APP_URL=https://wiki.example.com:8443 + - APP_URL=http://localhost:8080 + # APP_KEY is used for encryption where needed, so needs to be persisted to + # preserve decryption abilities. + # Can run `php artisan key:generate` to generate a key + - APP_KEY=SomeRandomStringWith32Characters volumes: - uploads:/var/www/bookstack/public/uploads - storage-uploads:/var/www/bookstack/storage/uploads diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 6a2455fa..7d5dea20 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,86 +3,43 @@ set -e echoerr() { echo "$@" 1>&2; } +check_vars_exist() { + var_names=("$@") + + for var_name in "${var_names[@]}"; do + if [ -z "${!var_name}" ]; then + echoerr "error: missing ${var_name} environment variable" + exit 1 + fi + done +} + # Split out host and port from DB_HOST env variable IFS=":" read -r DB_HOST_NAME DB_PORT <<< "$DB_HOST" DB_PORT=${DB_PORT:-3306} -if [ ! -f ".env" ]; then - if [[ "${DB_HOST}" ]]; then - cat > ".env" <&2 'error: missing DB_HOST environment variable' - exit 1 - fi +# Check a number of essential variables are set +check_vars_exist \ + APP_KEY \ + APP_URL \ + DB_DATABASE \ + DB_HOST \ + DB_PASSWORD \ + DB_PORT \ + DB_USERNAME + +if [ -n "${FILE_UPLOAD_SIZE_LIMITS}" ]; then + echo "Note: If you're setting FILE_UPLOAD_SIZE_LIMITS to more than 10M, you" + echo "may also need to modify the php.ini file." + echo "See:" + echo "https://github.com/solidnerd/docker-bookstack/issues/423" fi echoerr "wait-for-db: waiting for ${DB_HOST_NAME}:${DB_PORT}" @@ -102,9 +59,6 @@ else echoerr "wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST_NAME}:${DB_PORT}" fi -echo "Generating Key..." -php artisan key:generate --show - echo "Starting Migration..." php artisan migrate --force diff --git a/php.ini b/php.ini index 8c04c367..3b9c045a 100644 --- a/php.ini +++ b/php.ini @@ -1,4 +1,4 @@ [PHP] - +memory_limit = 256M post_max_size = 10M upload_max_filesize = 10M diff --git a/scripts/update_dockerfile.sh b/scripts/update_dockerfile.sh new file mode 100755 index 00000000..e203e0ff --- /dev/null +++ b/scripts/update_dockerfile.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +echo "Fetching latest Bookstack release from GitHub API" + +BOOKSTACK_VERSION=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/BookstackApp/Bookstack/releases/latest | \ + jq -r .tag_name +) + +echo "Found latest version: ${BOOKSTACK_VERSION}" + +# Get the root of the Git repository in order to correctly path e.g. Dockerfile +GIT_ROOT=$(git rev-parse --show-toplevel) + +echo "Updating Dockerfile.." +sed \ + -i '' \ + -e "s/^ENV BOOKSTACK_VERSION=.*/ENV BOOKSTACK_VERSION=${BOOKSTACK_VERSION}/" \ + "${GIT_ROOT}/Dockerfile" + +git add "${GIT_ROOT}/Dockerfile" +git commit -S -m "feat: update Dockerfile to use Bookstack ${BOOKSTACK_VERSION}" diff --git a/scripts/update_tags_and_docs.sh b/scripts/update_tags_and_docs.sh new file mode 100755 index 00000000..51c8edec --- /dev/null +++ b/scripts/update_tags_and_docs.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Get the root of the Git repository in order to correctly path e.g. Dockerfile +GIT_ROOT=$(git rev-parse --show-toplevel) + +# Extract the version from the Dockerfile, as there could have been a new +# release since the last run. + +BOOKSTACK_VERSION=$(awk \ + '/ENV BOOKSTACK_VERSION/{split($2,b,"="); print b[2]}' \ + "${GIT_ROOT}/Dockerfile" +) + +echo "Extracted version: ${BOOKSTACK_VERSION}" + +# Remove the 'v' for our tags +BOOKSTACK_VERSION="${BOOKSTACK_VERSION/#v/}" +# Remove leading zeros to make the version fit a SemVer-shaped hole +BOOKSTACK_VERSION="${BOOKSTACK_VERSION/.0/.}" + +# If the version only has one decimal dot in it, it doesn't have a patch +# version and one should be added to ensure semver-shape. +BS_DECIMALS="${BOOKSTACK_VERSION//[^.]}" +if [[ "${#BS_DECIMALS}" -eq "1" ]]; then + BOOKSTACK_VERSION="${BOOKSTACK_VERSION}.0" +fi + +echo "Tag name: ${BOOKSTACK_VERSION}" + +read -p "Is the tag name correct? (y/n)" -n 1 -r +echo +if ! [[ "${REPLY}" =~ ^[Yy]$ ]]; then + echo "Aborting.." + exit 1 +fi + +git tag -s -a "${BOOKSTACK_VERSION}" -m "Release version ${BOOKSTACK_VERSION}" +git push --tags + +echo "Extracting old version info.." +OLD_BS_VERSION="$(cat VERSION)" + +echo "Updating README and reference docker-compose.yml.." +sed \ + -i '' \ + -e "s/${OLD_BS_VERSION}/${BOOKSTACK_VERSION}/g" \ + "${GIT_ROOT}/README.md" \ + "${GIT_ROOT}/docker-compose.yml" + +echo "Updating VERSION file.." +echo "${BOOKSTACK_VERSION}" > "${GIT_ROOT}/VERSION" + +git add \ + "${GIT_ROOT}/README.md" \ + "${GIT_ROOT}/docker-compose.yml" \ + "${GIT_ROOT}/VERSION" + +git commit -S -m "doc: update documentation to reference ${BOOKSTACK_VERSION}" +git push