-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (146 loc) · 5.03 KB
/
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
name: Build test project
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: meow
jobs:
init:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
target:
- go_builder
steps:
- uses: actions/checkout@v4
- name: Load cache for builder - ${{ matrix.target }}
uses: actions/cache@v3
with:
path: dockerCache
key: docker-cache-${{ runner.os }}-${{ matrix.target }}
- name: Install docker buildx
uses: docker/setup-buildx-action@v3
- name: Preparing builder - ${{ matrix.target }}
uses: docker/build-push-action@v3
with:
file: ./base.Dockerfile
context: .
tags: base:${{ matrix.target }}
target: ${{ matrix.target }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- name: Save docker image
run: |
docker images
mkdir images
docker save -o images/${{ matrix.target }}.tar base:${{ matrix.target }}
- name: Save image ${{ matrix.target }} to cache
uses: actions/cache@v3
with:
path: images
key: docker-images-${{ runner.os }}
# docker save -o /tmp/${{ matrix.target }}.tar base:${{ matrix.target }}
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.target }}
# path: /tmp/${{ matrix.target }}.tar
# - name: Log into registry
# run: |
# echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin
# - uses: actions/checkout@v4
# - name: Start build pingserver
# run: |
# docker images
#
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-pingserver
# echo IMAGE_ID=$IMAGE_ID
#
# docker build -f ./apps/pingserver/Dockerfile \
# --tag $IMAGE_NAME \
# .
#
# docker tag $IMAGE_NAME $IMAGE_ID:latest
# docker push $IMAGE_ID:latest
backend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- init
strategy:
matrix:
target:
- pingserver
steps:
- name: Log into registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin
- uses: actions/checkout@v4
- name: Restore cached dependencies
uses: actions/cache@v3
with:
path: images
key: docker-images-${{ runner.os }}
- name: Load image
run: |
docker load --input images/go_builder.tar
docker image ls -a
# - name: Install docker buildx
# uses: docker/setup-buildx-action@v3
# - name: Preparing builder - ${{ matrix.target }}
# uses: docker/build-push-action@v3
# with:
# file: ./apps/${{ matrix.target }}/Dockerfile
# context: .
# tags: docker.pkg.github.com/${{ github.repository }}/${{ env.IMAGE_NAME }}-${{ matrix.target }}:latest
# cache-from: type=gha
# cache-to: type=gha,mode=max
# load: true
# build-args: PATH_TO_MAIN=./apps/${{ matrix.target }}
- name: Start build ${{ matrix.target }}
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }}
echo IMAGE_ID=$IMAGE_ID
PATH_TO_MAIN=./apps/${{ matrix.target }}
echo PATH_TO_MAIN=$PATH_TO_MAIN
docker build -f $PATH_TO_MAIN/Dockerfile \
--build-arg PATH_TO_MAIN=$PATH_TO_MAIN \
--tag $IMAGE_ID:latest \
-t bld:${{ matrix.target }} \
.
docker push $IMAGE_ID:latest
# env:
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }}
# PATH_TO_MAIN=./apps/${{ matrix.target }}
# - name: Preparing build ${{ matrix.target }}
# run: |
# docker images
# echo "export IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }}" >> $GITHUB_ENV
# echo IMAGE_ID=$IMAGE_ID
# echo "export PATH_TO_MAIN=./apps/${{ matrix.target }}" >> $GITHUB_ENV
# echo PATH_TO_MAIN=$PATH_TO_MAIN
# - name: Push build ${{ matrix.target }}
# run: |
# echo IMAGE_ID=$IMAGE_ID
# echo PATH_TO_MAIN=$PATH_TO_MAIN
# export IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME-${{ matrix.target }}
# export PATH_TO_MAIN=./apps/${{ matrix.target }}
#
# docker build -f $PATH_TO_MAIN/Dockerfile \
# --build-arg PATH_TO_MAIN=$PATH_TO_MAIN \
# --tag $IMAGE_ID:latest \
# -t bld:${{ matrix.target }} \
# .
#
# docker tag $IMAGE_NAME $IMAGE_ID:latest
# docker push $IMAGE_ID:latest