Skip to content

Build fastrl images #979

Build fastrl images

Build fastrl images #979

Workflow file for this run

name: Build fastrl images
on:
schedule:
- cron: '1 6 * * *'
workflow_dispatch: #allows you to trigger manually
push:
branches:
- main
- update_nbdev_docs
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
build_type: [prod, dev]
steps:
- name: Copy This Repository Contents
uses: actions/checkout@main
- 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: 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 --cache-from ${IMAGE_NAME}:latest --build-arg BUILD=${BUILD_TYPE} \
docker 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 }}