Files
spacedrive/.github/workflows/server.yml
Vítor Vasconcellos fbaf6ab886 [ENG-811] Fix server Dockerfile + create CI workflow to build and publish docker image (#1012)
* Fix server docker build failing due to apt locking error
 - Replace ffmpeg dep with only the libav* and related required lib (reduce size)
 - Add warning to tauri build command when DMG background is missing
 - Minor rust fmt

* Enable assets feature for server Dockerfile
 - Fix web app not using the correct address in prod
 - Add build step for web assets in server Dockerfile

* Enable repository to be defined in server's Dockerfile
 - Enable server's release workflow to specify which repository to build to allow external PRs to work

* Fix pnpm docker cache not working
2023-06-25 15:16:11 +00:00

63 lines
1.9 KiB
YAML

name: Server release
on:
workflow_dispatch:
jobs:
build-server:
name: Build a docker image for spacedrive server
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
platforms: linux/amd64
driver-opts: |
image=moby/buildkit:master
network=host
- name: Determine image name & tag
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" == "release" ]; then
export IMAGE_TAG=${GITHUB_REF##*/}
else
export IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
fi
export GITHUB_REPOSITORY_LOWER=$(echo $GITHUB_REPOSITORY | awk '{print tolower($0)}')
export IMAGE_NAME="ghcr.io/$GITHUB_REPOSITORY_LOWER/server"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "Building $IMAGE_NAME:$IMAGE_TAG"
- name: Build Docker image
shell: bash
run: |
docker build ./apps/server/docker --tag $IMAGE_NAME:$IMAGE_TAG --build-arg="REPO=${GITHUB_REPOSITORY}" --build-arg="REPO_REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
- name: Push Docker image
shell: bash
run: |
docker push $IMAGE_NAME:$IMAGE_TAG
- name: Tag & push image as latest staging image
if: ${{ github.event_name != 'release' }}
shell: bash
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:staging
docker push $IMAGE_NAME:staging
- name: Tag & push image as latest production image
if: ${{ github.event_name == 'release' }}
shell: bash
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:production
docker push $IMAGE_NAME:production