-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (76 loc) · 2.55 KB
/
fastrl-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Build fastrl images
on:
schedule:
- cron: '1 6 * * *'
workflow_dispatch: #allows you to trigger manually
push:
branches:
- main
- update_nbdev_docs
- feature/ppo
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
build_type: [dev]
# build_type: [prod, dev]
steps:
- name: Copy This Repository Contents
uses: actions/checkout@v2
with:
submodules: recursive
- 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 --build-arg BUILD=${BUILD_TYPE} \
docker build --cache-from ${IMAGE_NAME}:latest --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 }}