generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 11
76 lines (68 loc) · 2.35 KB
/
docker.yaml
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
name: Build deepflash2 images
on:
schedule:
- cron: '1 6 * * *'
workflow_dispatch: #allows you to trigger manually
push:
branch:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [prod] #dev currently not in use
steps:
- name: Copy This Repository Contents
uses: actions/checkout@main
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Copy Repository Contents
uses: actions/checkout@main
with:
repository: 'matjesg/deepflash2'
- 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.ini')
cfg = config['DEFAULT']
print(f"::set-output name=version::{cfg['version']}")
btype = os.getenv('BUILD_TYPE')
assert os.getenv('BUILD_TYPE') in ['prod', 'dev'], "BUILD_TYPE must be either 'prod' or 'dev'"
if btype != 'prod':
image_name = f'matjes/deepflash2-{btype}'
else:
image_name = 'matjes/deepflash2'
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
docker pull ${IMAGE_NAME}:latest || true
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 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 }}