-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mimimix
committed
Jan 16, 2024
1 parent
91aa9e1
commit e7347c6
Showing
1 changed file
with
57 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,52 +7,44 @@ on: | |
branches: [ main ] | ||
|
||
env: | ||
IMAGE_NAME: meow | ||
PROJECT_NAME: test | ||
|
||
jobs: | ||
init: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
target: | ||
- go_builder | ||
steps: | ||
- uses: TooMuch4U/[email protected] | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- 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 }} | ||
- run: | | ||
CURRENT_BUILD_NAME = ${{ PROJECT_NAME }}_base:${{ matrix.target }} | ||
docker build -f ./base.Dockerfile \ | ||
-t ${{ CURRENT_BUILD_NAME }} \ | ||
--target ${{ matrix.target }} \ | ||
--tag base:${{ matrix.target }} | ||
--cache-from type=gha,scope=${{ CURRENT_BUILD_NAME }} \ | ||
--cache-to type=gha,mode=max,scope=${{ CURRENT_BUILD_NAME }} \ | ||
. | ||
# - 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 | ||
|
||
backend: | ||
runs-on: ubuntu-latest | ||
runs-on: self-hosted | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
@@ -63,53 +55,37 @@ jobs: | |
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: Install docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Load image | ||
- uses: TooMuch4U/[email protected] | ||
- name: Log into github packages | ||
run: | | ||
docker load --input images/go_builder.tar | ||
docker image ls -a | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: docker.pkg.github.com | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- 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 }}/meow-${{ matrix.target }}:latest | ||
#cache-from: type=gha | ||
#cache-to: type=gha,mode=max | ||
# load: true | ||
build-args: PATH_TO_MAIN=./apps/${{ matrix.target }} | ||
push: true | ||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin | ||
- uses: actions/checkout@v4 | ||
# - 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 }}/meow-${{ matrix.target }}:latest | ||
# cache-from: type=gha | ||
# cache-to: type=gha,mode=max | ||
## load: true | ||
# build-args: PATH_TO_MAIN=./apps/${{ matrix.target }} | ||
# push: true | ||
|
||
# - name: Start build ${{ matrix.target }} ${{ IMAGE_NAME }} | ||
# 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 buildx build -f $PATH_TO_MAIN/Dockerfile \ | ||
# --build-arg PATH_TO_MAIN=$PATH_TO_MAIN \ | ||
# --tag $IMAGE_ID:latest \ | ||
# --cache-from type=gha \ | ||
# --cache-to type=gha,mode=max \ | ||
# -t bld:${{ matrix.target }} \ | ||
# . | ||
# | ||
# docker push $IMAGE_ID:latest | ||
- name: Start build ${{ PROJECT_NAME }} - ${{ matrix.target }} | ||
run: | | ||
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ PROJECT_NAME }}-${{ matrix.target }} | ||
echo START BUILD WITH 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 \ | ||
# --cache-from type=gha \ | ||
# --cache-to type=gha,mode=max \ | ||
-t ${{ PROJECT_NAME }}:${{ matrix.target }} \ | ||
. | ||
docker push $IMAGE_ID:latest |