Build fastrl images #1314
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build fastrl images | |
on: | |
schedule: | |
- cron: '1 6 * * *' | |
workflow_dispatch: #allows you to trigger manually | |
push: | |
branches: | |
- main | |
- update_nbdev_docs | |
- refactor/advantage-buffer | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
build_type: [dev] | |
# build_type: [prod, dev] | |
steps: | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
root-reserve-mb: 35000 | |
swap-size-mb: 1024 | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
- name: Copy This Repository Contents | |
uses: actions/checkout@v2 | |
# with: | |
# submodules: recursive | |
- name: Build | |
run: | | |
echo "Free space:" | |
df -h | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
architecture: 'x64' | |
- name: Copy settings.ini file | |
run: | | |
wget https://raw.githubusercontent.com/josiahls/fastrl/master/settings.ini | |
- name: get version from settings.ini and create image name | |
id: get_variables | |
run: | | |
from configparser import ConfigParser | |
import os | |
from pathlib import Path | |
config = ConfigParser() | |
settings = Path('settings.ini') | |
assert settings.exists(), 'Not able to read or download settings.ini file.' | |
config.read(settings) | |
cfg = config['DEFAULT'] | |
print(f"::set-output name=version::{cfg['version']}") | |
btype = os.getenv('BUILD_TYPE') | |
assert btype in ['prod', 'dev'], "BUILD_TYPE must be either prod, dev or course" | |
if btype != 'prod': | |
image_name = f'josiahls/fastrl-{btype}' | |
else: | |
image_name = 'josiahls/fastrl' | |
print(f"::set-output name=image_name::{image_name}") | |
shell: python | |
env: | |
BUILD_TYPE: ${{ matrix.build_type }} | |
# - name: Cache Docker layers | |
# if: always() | |
# uses: actions/cache@v3 | |
# with: | |
# path: /tmp/.buildx-cache | |
# key: ${{ runner.os }}-buildx-${{ github.sha }} | |
# restore-keys: | | |
# ${{ runner.os }}-buildx- | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v3 | |
- name: build and tag container | |
run: | | |
export DOCKER_BUILDKIT=1 | |
# We need to clear the previous docker images | |
docker system prune -fa | |
docker pull ${IMAGE_NAME}:latest || true | |
# docker build --build-arg BUILD=${BUILD_TYPE} \ | |
# docker buildx create --use | |
# docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --build-arg BUILD=${BUILD_TYPE} \ | |
# -t ${IMAGE_NAME}:latest \ | |
# -t ${IMAGE_NAME}:${VERSION} \ | |
# -t ${IMAGE_NAME}:$(date +%F) \ | |
# -f fastrl.Dockerfile . | |
docker buildx build --build-arg BUILD=${BUILD_TYPE} \ | |
-t ${IMAGE_NAME}:latest \ | |
-t ${IMAGE_NAME}:${VERSION} \ | |
-t ${IMAGE_NAME}:$(date +%F) \ | |
-f fastrl.Dockerfile . | |
env: | |
VERSION: ${{ steps.get_variables.outputs.version }} | |
IMAGE_NAME: ${{ steps.get_variables.outputs.image_name }} | |
BUILD_TYPE: ${{ matrix.build_type }} | |
- name: push images | |
run: | | |
echo ${PASSWORD} | docker login -u $USERNAME --password-stdin | |
docker push ${IMAGE_NAME} | |
env: | |
USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
IMAGE_NAME: ${{ steps.get_variables.outputs.image_name }} |