Skip to content

Commit

Permalink
Add env-flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Oct 15, 2024
1 parent 8ff15d8 commit b44ea1a
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 155 deletions.
47 changes: 41 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
cancel-in-progress: true

jobs:
images:
linux-images:
runs-on: ubuntu-latest

strategy:
Expand All @@ -31,6 +31,7 @@ jobs:
- env-archlinux
- env-debian
- env-fedora
- env-flutter
- env-opensuse
- env-sphinx
- env-ubuntu:14.04
Expand All @@ -47,7 +48,7 @@ jobs:
- toolchain-mips-openwrt-linux-atheros
- toolchain-linux-android

name: ${{ matrix.image }}
name: linux/${{ matrix.image }}

env:
CACHE_FROM: /tmp/.buildx-cache
Expand Down Expand Up @@ -81,20 +82,54 @@ jobs:
run: |
if [[ $ENABLE_PUSH = 1 ]]; then \
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
./make.sh --push ${{ matrix.image }}
./make.py --push ${{ matrix.image }}
else
./make.sh ${{ matrix.image }}
./make.py ${{ matrix.image }}
fi
- name: Move cache
if: always()
run: |
rm -rf ${CACHE_FROM}
mv ${CACHE_TO} ${CACHE_FROM}
if [ -e ${CACHE_TO} ]; then
rm -rf ${CACHE_FROM}
mv ${CACHE_TO} ${CACHE_FROM}
fi
- name: Save cache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ env.CACHE_FROM }}
key: ${{ matrix.image }}-${{ github.sha }}

windows-images:
runs-on: windows-latest

strategy:
fail-fast: false
matrix:
image:
- env-flutter

name: windows/${{ matrix.image }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup env
if: |
github.repository_owner == 'roc-streaming' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
run: |
echo "ENABLE_PUSH=1" >> $GITHUB_ENV
- name: Run docker
run: |
if ($env:ENABLE_PUSH -eq 1) {
docker login -u $env:DOCKER_USER -p $env:DOCKER_PASSWORD
python make.py --push $env:matrix_image
} else {
python make.py $env:matrix_image
}
15 changes: 15 additions & 0 deletions images/env-flutter/Dockerfile.android
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ghcr.io/cirruslabs/flutter:stable

RUN find /sdks -type d -exec chmod a+rwx '{}' ';'
RUN find /sdks -type f -exec chmod a+rw '{}' ';'

RUN find /opt -type d -exec chmod a+rwx '{}' ';'
RUN find /opt -type f -exec chmod a+rw '{}' ';'

RUN find /root -type d -exec chmod a+rwx '{}' ';'
RUN find /root -type f -exec chmod a+rw '{}' ';'

USER root
ENV HOME=/root

RUN git config --global --add safe.directory /sdks/flutter
15 changes: 15 additions & 0 deletions images/env-flutter/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM openpriv/flutter-desktop:linux-fstable-3.10.2

RUN find /sdks -type d -exec chmod a+rwx '{}' ';'
RUN find /sdks -type f -exec chmod a+rw '{}' ';'

RUN find /opt -type d -exec chmod a+rwx '{}' ';'
RUN find /opt -type f -exec chmod a+rw '{}' ';'

RUN find /root -type d -exec chmod a+rwx '{}' ';'
RUN find /root -type f -exec chmod a+rw '{}' ';'

USER root
ENV HOME=/root

RUN git config --global --add safe.directory /sdks/flutter
1 change: 1 addition & 0 deletions images/env-flutter/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM openpriv/flutter-desktop:windows-sdk30-fstable-3.10.2
4 changes: 4 additions & 0 deletions images/env-flutter/images.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DOCKERFILE;ARGS (comma-separated list);TAG;OS
Dockerfile.android;;android;linux
Dockerfile.linux;;linux;linux
Dockerfile.windows;;windows;windows
3 changes: 2 additions & 1 deletion images/env-sphinx/requirements.unversioned.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Requirements file used to install latest, which we then freeze.
Sphinx
breathe
mkdocs
Sphinx
sphinxemoji
103 changes: 103 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env python3

import argparse
import csv
import os
import platform
import subprocess

DRY_RUN = False

def run_cmd(*args):
print(f"-- {' '.join(args)}")
if not DRY_RUN:
subprocess.check_call(args)

def print_msg(msg):
if platform.system() != 'Windows':
print(f'-- \033[1;35m{msg}\033[0m')
else:
print(msg)

parser = argparse.ArgumentParser()
parser.add_argument('-n', '--dry-run', action='store_true', help="don't run commands, just print them")
parser.add_argument('-p', '--push', action='store_true', help="push image after building")
parser.add_argument('-C', '--no-cache', action='store_true', help="pass --no-cache to docker build")
parser.add_argument('-P', '--no-pull', action='store_true', help="don't pass --pull to docker build")
parser.add_argument('image', nargs='*', default=None)

args = parser.parse_args()

DRY_RUN = args.dry_run

os.chdir(os.path.dirname(__file__))

if args.image:
images = args.image
else:
images = sorted(os.listdir('images'))

for image in images:
if ':' in image:
image_shortname, image_tag = image.split(':')
else:
image_shortname = image
image_tag = ''

image_fullname = f'rocstreaming/{image_shortname}'
image_dir = f'images/{image_shortname}'

os.chdir(image_dir)

with open('images.csv') as fp:
for n, line in enumerate(fp.readlines()):
if n == 0:
continue
parts = line.strip().split(';')
if len(parts) == 4:
dockerfile, build_args, tag, osname = parts
else:
dockerfile, build_args, tag = parts
osname = 'linux'

if not dockerfile:
dockerfile = 'Dockerfile'
if not tag:
tag = dockerfile.split('/')[0]

if '/' in dockerfile:
context = dockerfile.split('/')[0]
else:
context = '.'

if image_tag and tag != image_tag:
continue
if osname != platform.system().lower():
continue

print_msg(f'processing image {image_fullname}:{tag}')

docker_args = []
if not args.no_pull:
docker_args.append('--pull')
if args.no_cache:
docker_args.append('--no-cache')

docker_args.extend([
'-f', dockerfile,
'-t', f'{image_fullname}:{tag}',
'--output', 'type=docker',
])

if build_args:
for arg in build_args.split(','):
docker_args.extend(['--build-arg', arg.replace(' ', '_')])

docker_args.append(context)

run_cmd('docker', 'build', *docker_args)

if args.push:
run_cmd('docker', 'push', f'{image_fullname}:{tag}')

os.chdir('../..')
148 changes: 0 additions & 148 deletions make.sh

This file was deleted.

0 comments on commit b44ea1a

Please sign in to comment.