-
Notifications
You must be signed in to change notification settings - Fork 4
256 lines (214 loc) · 7.69 KB
/
docker_build.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Build and publish container images
#
# There are three images in this repo we want to build and publish individually:
# - GISPy
# - ISIS
# - ASP
#
# The images should be tagged as 'latest' and "$VERSION", where the version
# will point unequivocally to a git commit/tag of this repo.
# 'latest' will be the latest version of repository in 'stable' branch.
#
# Reference docs:
# - docs.github.com/en/actions/publishing-packages/publishing-docker-images
name: Build and Publish Containers
# Controls when the action will run. Triggers the workflow on push request, or repository dispatch
on:
# Runs when pushing to 'stable' branch
push:
# branches:
# - 'stable'
# - 'test'
branches-ignore:
- 'master'
tags:
- '*'
# Run in every PR too
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# gispy:
# uses: ./.github/workflows/workflow_build.yml
# with:
# image_name: ${{ vars.DOCKERHUB_USERNAME }}/jupyter-gispy
# context_path: ./dockerfiles
# dockerfile_path: ./dockerfiles/gispy.dockerfile
# secrets: inherit
# isis:
# uses: ./.github/workflows/workflow_build.yml
# with:
# image_name: ${{ vars.DOCKERHUB_USERNAME }}/jupyter-isis
# context_path: ./dockerfiles
# dockerfile_path: ./dockerfiles/isis.dockerfile
# secrets: inherit
gispy:
runs-on: ubuntu-latest
env:
USER_ORG: ${{ vars.DOCKERHUB_USERNAME }}
SERVICE: jupyter-gispy
REPO: ${USER_ORG}/${SERVICE}
steps:
- # https://github.com/marketplace/actions/checkout
name: Checkout
uses: actions/checkout@v4
- name: Build image
run: |
docker compose build ${{ env.SERVICE }}
- name: Tag image
if: ${{ github.event_name == 'push' }}
run: |
NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
docker tag $NEW_IMAGE ${{ env.REPO }}:$GITHUB_REF_NAME
- name: Tag 'latest' image
if: ${{ github.ref_type == 'tag' }}
run: |
NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
docker tag $NEW_IMAGE ${{ env.REPO }}:latest
# DATE=`date +%Y%m%d`
# docker tag $NEW_IMAGE ${{ env.REPO }}:$DATE
# - name: Tag image with SHA hash
# if: ${{ github.event_name == 'push' }}
# run: |
# IMAGE_SHA=`docker images -q $NEW_IMAGE`
# docker tag $NEW_IMAGE ${USERNAME}/jupyter-gispy:$IMAGE_SHA
- # https://github.com/marketplace/actions/docker-login
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image
run: >
docker image ls
| tail -n+2 | awk '{print $1":"$2}'
| grep "${{ env.REPO }}"
| xargs -I'{}' docker push {}
isis:
runs-on: ubuntu-latest
env:
USER_ORG: ${{ vars.DOCKERHUB_USERNAME }}
SERVICE: jupyter-isis
REPO: ${USER_ORG}/${SERVICE}
steps:
- # https://github.com/marketplace/actions/checkout
name: Checkout
uses: actions/checkout@v4
- name: Load .env file
uses: xom9ikk/dotenv@v2
- name: Build image
run: |
docker compose build ${{ env.SERVICE }}
- name: Tag image
if: ${{ github.event_name == 'push' }}
run: |
NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
docker tag $NEW_IMAGE ${{ env.REPO }}:$GITHUB_REF_NAME
- name: Tag 'latest' image
if: ${{ github.ref_type == 'tag' }}
run: |
NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
docker tag $NEW_IMAGE ${{ env.REPO }}:latest
docker tag $NEW_IMAGE ${{ env.REPO }}:${ISIS_VERSION}
# DATE=`date +%Y%m%d`
# docker tag $NEW_IMAGE ${{ env.REPO }}:$DATE
# - name: Tag image with SHA hash
# if: ${{ github.event_name == 'push' }}
# run: |
# IMAGE_SHA=`docker images -q $NEW_IMAGE`
# docker tag $NEW_IMAGE ${USERNAME}/jupyter-gispy:$IMAGE_SHA
- # https://github.com/marketplace/actions/docker-login
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image
run: >
docker image ls
| tail -n+2 | awk '{print $1":"$2}'
| grep "${{ env.REPO }}"
| xargs -I'{}' docker push {}
# - name: Save image
# run: |
# NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
# docker save --output /tmp/image.tar $NEW_IMAGE
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: isis_image
# path: /tmp/image.tar
# - name: List images
# run: |
# docker image ls -a
# isis-asp:
# needs: isis
# runs-on: ubuntu-latest
# env:
# USER_ORG: ${{ vars.DOCKERHUB_USERNAME }}
# SERVICE: jupyter-isis-asp
# REPO: ${USER_ORG}/${SERVICE}
# steps:
# - # https://github.com/marketplace/actions/checkout
# name: Checkout
# uses: actions/checkout@v4
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: isis_image
# path: /tmp
# - name: Load image
# run: |
# docker load --input /tmp/image.tar
# docker image ls -a
# - name: Load .env file
# uses: xom9ikk/dotenv@v2
- name: Redefine ENV for isis-asp
run: |
SERVICE="${{ env.SERVICE }}-asp"
REPO="${{ env.USER_ORG }}/$SERVICE"
echo "SERVICE=$SERVICE" >> $GITHUB_ENV
echo "REPO=$REPO" >> $GITHUB_ENV
- name: Build image
run: |
docker compose build ${SERVICE}
# docker compose build ${{ env.SERVICE }}
- name: Tag image
if: ${{ github.event_name == 'push' }}
run: |
NEW_IMAGE=`docker compose config --images ${SERVICE}`
docker tag $NEW_IMAGE ${REPO}:$GITHUB_REF_NAME
# NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
# docker tag $NEW_IMAGE ${{ env.REPO }}:$GITHUB_REF_NAME
- name: Tag 'latest' image
if: ${{ github.ref_type == 'tag' }}
run: |
NEW_IMAGE=`docker compose config --images ${SERVICE}`
docker tag $NEW_IMAGE ${REPO}:latest
docker tag $NEW_IMAGE ${REPO}:${ISIS_VERSION}-${ASP_VERSION}
# NEW_IMAGE=`docker compose config --images ${{ env.SERVICE }}`
# docker tag $NEW_IMAGE ${{ env.REPO }}:latest
# docker tag $NEW_IMAGE ${{ env.REPO }}:${ISIS_VERSION}-${ASP_VERSION}
# DATE=`date +%Y%m%d`
# docker tag $NEW_IMAGE ${{ env.REPO }}:$DATE
# - name: Tag image with SHA hash
# if: ${{ github.event_name == 'push' }}
# run: |
# IMAGE_SHA=`docker images -q $NEW_IMAGE`
# docker tag $NEW_IMAGE ${USERNAME}/jupyter-gispy:$IMAGE_SHA
- # https://github.com/marketplace/actions/docker-login
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image
run: >
docker image ls
| tail -n+2 | awk '{print $1":"$2}'
| grep "${REPO}"
| xargs -I'{}' docker push {}
# docker image ls
# | tail -n+2 | awk '{print $1":"$2}'
# | grep "${{ env.REPO }}"
# | xargs -I'{}' docker push {}