Skip to content

Commit

Permalink
ci: build and push linux docker image to aws
Browse files Browse the repository at this point in the history
  • Loading branch information
agnarbjoernstad committed Jun 12, 2024
1 parent 6e5ed89 commit ad2fecd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:focal
USER root
ENV QT_VERSION=5.15.2
ENV DEBIAN_FRONTEND noninteractive
ENV DISPLAY :99
ENV QMAKESPEC linux-g++-64
ENV QT_PATH /opt/Qt
ENV QT_DESKTOP $QT_PATH/${QT_VERSION}/gcc_64
ENV PATH /usr/lib/ccache:$QT_DESKTOP/bin:$PATH
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Oslo
RUN apt-get update && apt-get install -y \
curl \
libsdl2-dev \
gstreamer1.0-gl \
qt5-default \
libxcb-xinerama0 -y
RUN groupadd -r qgc -g 1000 && useradd -m -u 1000 -r -g qgc qgc
RUN mkdir app
ARG APPIMAGE_PATH="QGroundControl.AppImage"
COPY ${APPIMAGE_PATH} /app
RUN chmod 755 /app
WORKDIR /app
USER qgc
ENV APPIMAGE_EXTRACT_AND_RUN=1
CMD ["./QGroundControl.AppImage"]
34 changes: 30 additions & 4 deletions .github/workflows/linux_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ defaults:
shell: bash

env:
SOURCE_DIR: ${{ github.workspace }}
QT_VERSION: 5.15.2
ARTIFACT: QGroundControl.AppImage
BUILD_TYPE: ${{ fromJSON('["DailyBuild", "StableBuild"]')[ github.ref_type == 'tag' || github.ref == 'aviant/V4.2' ] }}
SOURCE_DIR: ${{ github.workspace }}
QT_VERSION: 5.15.2
ARTIFACT: QGroundControl.AppImage
BUILD_TYPE: ${{ fromJSON('["DailyBuild", "StableBuild"]')[ github.ref_type == 'tag' || github.ref == 'aviant/V4.2' ] }}
ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}

jobs:
build:
Expand Down Expand Up @@ -75,6 +77,30 @@ jobs:
path: ${{ runner.temp }}/shadow_build_dir/package/${{ env.ARTIFACT }}
retention-days: 1

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
if: startsWith(github.ref, 'refs/tags/')
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-north-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
if: startsWith(github.ref, 'refs/tags/')

- name: Build docker image
working-directory: ${{ runner.temp }}/shadow_build_dir
if: startsWith(github.ref, 'refs/tags/')
run: |
docker build --build-arg APPIMAGE_PATH=${{ runner.temp }}/shadow_build_dir/package/${{ env.ARTIFACT }} ${SOURCE_DIR}/.github/docker/Dockerfile -t ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest ${ECR_REGISTRY}/${ECR_REPOSITORY}:${{ github.ref_name }}
- name: Push docker image to AWS ecr
if: startsWith(github.ref, 'refs/tags/')
run: |
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down

0 comments on commit ad2fecd

Please sign in to comment.