automatically parse version of coolify for building prod image

This commit is contained in:
Andras Bacsai 2023-04-28 10:04:16 +02:00
parent a7c4e06bc3
commit bc6feed17f
3 changed files with 20 additions and 16 deletions

View File

@ -13,23 +13,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: |
/usr/local/share/ca-certificates
/var/cache/apt/archives
/var/lib/apt/lists
~/.cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Login to ghcr.io - name: Login to ghcr.io
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Version
id: version
run: |
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app php:8.2-alpine3.16 php bootstrap/getVersion.php)"|xargs >> $GITHUB_OUTPUT
- name: Build image and push to registry - name: Build image and push to registry
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
@ -37,4 +30,8 @@ jobs:
file: docker/prod-ssu/Dockerfile file: docker/prod-ssu/Dockerfile
platforms: linux/amd64 platforms: linux/amd64
push: true push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:4.0.0-nightly.0 tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
- uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }}

3
bootstrap/getVersion.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$version = include 'config/coolify.php';
echo $version['version'];

View File

@ -12,10 +12,14 @@ RUN apt-get -y autoremove \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
COPY --chmod=755 docker/prod-ssu/etc/s6-overlay/ /etc/s6-overlay/ COPY composer.json composer.lock ./
COPY --chown=9999:9999 . . RUN composer install --no-dev --no-interaction --no-plugins --no-scripts --prefer-dist
COPY --from=static-assets --chown=9999:9999 /app/public/build /var/www/html/public/build
COPY --chown=9999:9999 . .
RUN composer dump-autoload
COPY --from=static-assets --chown=9999:9999 /app/public/build ./public/build
COPY --chmod=755 docker/prod-ssu/etc/s6-overlay/ /etc/s6-overlay/
RUN composer install --no-dev --optimize-autoloader
RUN php artisan route:cache RUN php artisan route:cache
RUN php artisan view:cache RUN php artisan view:cache