Skip to content

Commit

Permalink
use upload artifacts instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lukey-luke committed Feb 3, 2025
1 parent 214f2f3 commit f0b8615
Showing 1 changed file with 139 additions and 108 deletions.
247 changes: 139 additions & 108 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ env:

jobs:
docker_build_rails_web_portal:
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: web-portal
IMAGE_TAG: ${{ github.sha }}
runs-on: self-hosted
steps:
- name: check gzip
run: gzip --version

- name: Install python3
run: sudo dnf install python3

Expand All @@ -37,6 +44,28 @@ jobs:
run: |
make ci-portal
- name: gzip the image
run: docker save dpc-$REPOSITORY:latest | gzip > $REPOSITORY_latest.tar.gz
- name: upload tar artifact
uses: actions/upload-artifact@v4
with:
name: dpc-$REPOSITORY
path: ${{ runner.temp }}/$REPOSITORY_latest.tar.gz.tar

docker_push_rails_web_portal_image:
runs-on: self-hosted
needs: docker_build_rails_web_portal
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: $REPOSITORY_latest.tar.gz.tar
path: ${{ runner.temp }}

- name: Load image
run: |
docker load --input ${{ runner.temp }}/myimage.tar
docker image ls -a
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -56,6 +85,8 @@ jobs:
docker tag dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:latest
docker tag dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
- name: success
run: "Did it work???"
# TODO add additional steps to push dpc-web-admin and dpc-web, see docker_build_all_portals below

# docker_build_all_portals:
Expand Down Expand Up @@ -134,111 +165,111 @@ jobs:
# if: ${{ always() }}
# run: ./scripts/cleanup-docker.sh

docker_build_java:
runs-on: self-hosted
steps:
- name: "Set up Ansible"
run: |
sudo dnf -y install python3 python3-pip
pip install ansible
- name: "Install npm for Postman tests"
run: |
sudo dnf -y install nodejs
npm --version
- name: Install docker compose manually
run: |
sudo mkdir -p /usr/local/lib/docker/cli-plugins
sudo curl -SL https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
sudo chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
- name: "Set up JDK 11"
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "corretto"
cache: maven

- name: Install Maven 3.6.3
run: |
export PATH="$PATH:/opt/maven/bin"
echo "PATH=$PATH" >> $GITHUB_ENV
if mvn -v; then echo "Maven already installed" && exit 0; else echo "Installing Maven"; fi
tmpdir="$(mktemp -d)"
curl -LsS https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xzf - -C "$tmpdir"
sudo rm -rf /opt/maven
sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven
- name: Clean maven
run: mvn -ntp -U clean

- name: "Checkout code"
uses: actions/checkout@v4

- name: Build ci app
id: api-build
run: |
export PATH=$PATH:~/.local/bin
make ci-app
# add extra commands to log docker containers during failure
- name: Consent Logs
if: ${{ failure() && steps.api-build.outcome == 'failure' }}
run: docker logs start-v1-app-consent-1
- name: Attribution Logs
if: ${{ failure() && steps.api-build.outcome == 'failure' }}
run: docker logs start-v1-app-attribution-1
- name: Aggregation Logs
if: ${{ failure() && steps.api-build.outcome == 'failure' }}
run: docker logs start-v1-app-aggregation-1
- name: Api Logs
if: ${{ failure() && steps.api-build.outcome == 'failure' }}
run: docker logs start-v1-app-api-1

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-dev-github-actions

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: ECR (1 of 4) - Push API
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: api
IMAGE_TAG: ${{ github.sha }}
run: |
docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
- name: ECR (2 of 4) - Push Attribution
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: attribution
IMAGE_TAG: ${{ github.sha }}
run: |
docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
- name: ECR (3 of 4) - Push Aggregation
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: aggregation
IMAGE_TAG: ${{ github.sha }}
run: |
docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
- name: ECR (4 of 4) - Push Consent
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: consent
IMAGE_TAG: ${{ github.sha }}
run: |
docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker_build_java:
# runs-on: self-hosted
# steps:
# - name: "Set up Ansible"
# run: |
# sudo dnf -y install python3 python3-pip
# pip install ansible
#
# - name: "Install npm for Postman tests"
# run: |
# sudo dnf -y install nodejs
# npm --version
#
# - name: Install docker compose manually
# run: |
# sudo mkdir -p /usr/local/lib/docker/cli-plugins
# sudo curl -SL https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
# sudo chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
# sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
#
# - name: "Set up JDK 11"
# uses: actions/setup-java@v3
# with:
# java-version: "11"
# distribution: "corretto"
# cache: maven
#
# - name: Install Maven 3.6.3
# run: |
# export PATH="$PATH:/opt/maven/bin"
# echo "PATH=$PATH" >> $GITHUB_ENV
# if mvn -v; then echo "Maven already installed" && exit 0; else echo "Installing Maven"; fi
# tmpdir="$(mktemp -d)"
# curl -LsS https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xzf - -C "$tmpdir"
# sudo rm -rf /opt/maven
# sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven
#
# - name: Clean maven
# run: mvn -ntp -U clean
#
# - name: "Checkout code"
# uses: actions/checkout@v4
#
# - name: Build ci app
# id: api-build
# run: |
# export PATH=$PATH:~/.local/bin
# make ci-app
#
# # add extra commands to log docker containers during failure
# - name: Consent Logs
# if: ${{ failure() && steps.api-build.outcome == 'failure' }}
# run: docker logs start-v1-app-consent-1
# - name: Attribution Logs
# if: ${{ failure() && steps.api-build.outcome == 'failure' }}
# run: docker logs start-v1-app-attribution-1
# - name: Aggregation Logs
# if: ${{ failure() && steps.api-build.outcome == 'failure' }}
# run: docker logs start-v1-app-aggregation-1
# - name: Api Logs
# if: ${{ failure() && steps.api-build.outcome == 'failure' }}
# run: docker logs start-v1-app-api-1
#
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: ${{ vars.AWS_REGION }}
# role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-dev-github-actions
#
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
#
# - name: ECR (1 of 4) - Push API
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: api
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
#
# - name: ECR (2 of 4) - Push Attribution
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: attribution
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
#
# - name: ECR (3 of 4) - Push Aggregation
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: aggregation
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
#
# - name: ECR (4 of 4) - Push Consent
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: consent
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker tag $REGISTRY/dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG

0 comments on commit f0b8615

Please sign in to comment.