Skip to content

Commit

Permalink
Simplify the LinkAce Docker setup (#502)
Browse files Browse the repository at this point in the history
- Removes the advanced image version where PHP and nginx are separated
- Replaces nginx with Caddy
- The release image is now ready to be used with SQLite without many hassles
- Adjusts the build processes accordingly
- Removes unnecessary config files
  • Loading branch information
Kovah committed Feb 6, 2024
1 parent e1571f1 commit c68dd90
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 428 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ _ide_*
/.git
/.idea
/.tmp
/database/*.sqlite
/storage/app/backups/*
/storage/debugbar/*
/storage/framework/cache/*
Expand Down
24 changes: 3 additions & 21 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Build regular LinkAce Docker image
name: Build the LinkAce Docker image

on:
push:
Expand Down Expand Up @@ -39,32 +39,14 @@ jobs:
DOCKER_IMAGE=linkace/linkace
DOCKER_IMAGE_GITUHB=ghcr.io/kovah/linkace
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest,${DOCKER_IMAGE_GITUHB}:${VERSION},${DOCKER_IMAGE_GITUHB}:latest"
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE_GITUHB}:${VERSION}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push advanced image
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./resources/docker/dockerfiles/release-multiplatform.Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.prep.outputs.tags }}

- name: Prepare simple build tags
id: prep-simple
run: |
DOCKER_IMAGE=linkace/linkace
DOCKER_IMAGE_GITHUB=ghcr.io/kovah/linkace
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION}-php-nginx,${DOCKER_IMAGE}:php-nginx,${DOCKER_IMAGE}:${VERSION}-simple,${DOCKER_IMAGE}:simple,${DOCKER_IMAGE_GITHUB}:${VERSION}-php-nginx,${DOCKER_IMAGE_GITHUB}:php-nginx,${DOCKER_IMAGE_GITHUB}:${VERSION}-simple,${DOCKER_IMAGE_GITHUB}:simple"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push simple image
uses: docker/build-push-action@v5
with:
context: .
file: ./resources/docker/dockerfiles/release-multiplatform-simple.Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.prep-simple.outputs.tags }}
77 changes: 13 additions & 64 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ on:
- main

jobs:

build-js:
name: Build assets for the package
build-package:
name: Build final dist package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Reconfigure Git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
- name: Use Node.js
uses: actions/setup-node@v2
with:
Expand All @@ -28,35 +22,6 @@ jobs:
npm ci
npm run production
- name: Upload built assets
uses: actions/upload-artifact@v3
with:
name: assets
path: public/assets/dist

- name: Upload mix manifest
uses: actions/upload-artifact@v3
with:
name: mix-manifest
path: public/mix-manifest.json

build-package:
name: Build final dist package
runs-on: ubuntu-latest
needs: build-js
steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v3
with:
name: assets
path: public/assets/dist

- uses: actions/download-artifact@v3
with:
name: mix-manifest
path: public

- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
Expand Down Expand Up @@ -86,15 +51,12 @@ jobs:
- name: Remove .env file
run: rm .env

- uses: thedoctor0/zip-release@master
with:
filename: linkace.zip
exclusions: '*.git*'

- uses: actions/upload-artifact@v3
with:
name: linkace-package
path: linkace.zip
path: |
.
!.git
build-package-docker:
name: Build final dist package for Docker setup
Expand All @@ -106,26 +68,13 @@ jobs:
run: |
mv .env.docker.production .env
chmod 0666 .env
mv docker-compose.production-simple.yml docker-compose.yml
mv docker-compose.production.yml docker-compose.yml
- uses: montudor/action-zip@v1
- uses: actions/upload-artifact@v4
with:
args: zip -qq linkace-package-docker-simple.zip docker-compose.yml .env LICENSE.md README.md

- uses: actions/upload-artifact@v3
with:
name: linkace-docker-simple
path: linkace-package-docker-simple.zip

- name: Rename files
run: mv docker-compose.production.yml docker-compose.yml

- uses: montudor/action-zip@v1
with:
args: zip -qq linkace-package-docker-advanced.zip docker-compose.yml .env nginx.conf nginx-ssl.conf LICENSE.md README.md

- uses: actions/upload-artifact@v3
with:
name: linkace-docker-advanced
path: linkace-package-docker-advanced.zip

name: linkace-docker
path: |
docker-compose.yml
.env
LICENSE.md
README.md
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ docker exec -it linkace-php composer run test
The Base image for LinkAce contains several packages and PHP extensions needed by LinkAce. It shortens the build time of the release images. This step is not needed by any developer working on LinkAce and is just a documentation for maintainers.

```bash
docker buildx build --push --platform "linux/amd64,linux/arm64,linux/arm/v7" -t linkace/base-image:php-8.2-alpine -f resources/docker/dockerfiles/release-base.Dockerfile .
docker buildx build --push --platform "linux/amd64,linux/arm64,linux/arm/v7" -t linkace/base-image:php-8.3-alpine -f resources/docker/dockerfiles/release-base.Dockerfile .
```
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function migrateNoteVisibility(): void

protected function addUserRoles(): void
{
Artisan::call('db:seed', ['--class' => 'RolesAndPermissionsSeeder']);
Artisan::call('db:seed', ['--class' => 'RolesAndPermissionsSeeder', '--force' => true]);

Schema::table('users', function (Blueprint $table) {
$table->timestamp('blocked_at')->nullable()->after('api_token');
Expand Down
38 changes: 0 additions & 38 deletions docker-compose.production-simple.yml

This file was deleted.

23 changes: 7 additions & 16 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,18 @@ services:
restart: unless-stopped
depends_on:
- db
ports:
- "0.0.0.0:80:80"
# Remove the hash of the following line if you want to use HTTPS for this container
#- "0.0.0.0:443:443"
volumes:
- ./.env:/app/.env
- ./backups:/app/storage/app/backups
- linkace_app:/app
- linkace_logs:/app/storage/logs

# --- nginx
nginx:
image: bitnami/nginx:1.24
restart: unless-stopped
ports:
- "0.0.0.0:80:8080"
#- "0.0.0.0:443:8443"
depends_on:
- app
volumes:
- linkace_app:/app
# Replace `nginx.conf` with `nginx-ssl.conf` and remove the hash from the following line
# if you want to use HTTPS for this container
- ./nginx.conf:/opt/bitnami/nginx/conf/server_blocks/linkace.conf:ro
#- /path/to/your/ssl/certificates:/certs:ro
# Remove the hash of the following line if you want to use HTTPS for this container
#- ./Caddyfile:/etc/caddy/Caddyfile:ro
#- ./caddy-data:/data/caddy

# --- Redis
redis:
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ services:
- .:/app:delegated
- ./resources/docker/php/php-dev.ini:/usr/local/etc/php/conf.d/php.ini:ro

# --- nginx
nginx:
image: bitnami/nginx:1.25
# --- Caddy
caddy:
image: caddy:2
ports:
- "80:8080"
- "80:80"
depends_on:
- php
volumes:
- .:/app:delegated
- ./resources/docker/nginx/dev.conf:/opt/bitnami/nginx/conf/server_blocks/linkace.conf:ro
- ./resources/docker/Caddyfile:/etc/caddy/Caddyfile:ro

# --- Redis
redis:
Expand Down
61 changes: 0 additions & 61 deletions nginx-ssl.conf

This file was deleted.

57 changes: 0 additions & 57 deletions nginx.conf

This file was deleted.

Loading

0 comments on commit c68dd90

Please sign in to comment.