Skip to content

Commit

Permalink
PHRAS-3826: push image to ecr (#4309)
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix authored May 3, 2023
1 parent 9da5a47 commit 85da4df
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
28 changes: 14 additions & 14 deletions .circleci/config.yml → .circleci/config_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@ workflows:
# oldfashion:
# jobs:
# - build
newfashion:
jobs:
- build_phraseanet-setup:
context: "AWS London"
- build_phraseanet-fpm:
context: "AWS London"
- build_phraseanet-worker:
context: "AWS London"
- build_phraseanet-nginx:
context: "AWS London"
- build_phraseanet-db:
context: "AWS London"
- build_phraseanet-elasticsearch:
context: "AWS London"
# newfashion:
# jobs:
# - build_phraseanet-setup:
# context: "AWS London"
# - build_phraseanet-fpm:
# context: "AWS London"
# - build_phraseanet-worker:
# context: "AWS London"
# - build_phraseanet-nginx:
# context: "AWS London"
# - build_phraseanet-db:
# context: "AWS London"
# - build_phraseanet-elasticsearch:
# context: "AWS London"
28 changes: 24 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,46 @@ on:

env:
PHRASEANET_DOCKER_TAG: ${{ github.head_ref }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
DEFAULT_REGISTRY: ghcr.io/${{ github.repository_owner }}
CACHE_REGISTRY: ghcr.io/${{ github.repository_owner }}
AWS_REGION: eu-west-2

jobs:
buid:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}

- name: Log into GitHub registry ${{ env.DEFAULT_REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ${{ env.DEFAULT_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

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

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

- name: Get tag name
if: github.event_name != 'pull_request'
shell: bash
run: echo "PHRASEANET_DOCKER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV

- name: build ${{ inputs.image }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
uses: docker/build-push-action@v4
with:
context: ${{ inputs.context }}
Expand All @@ -48,4 +66,6 @@ jobs:
cache-from: type=registry,ref=${{ env.CACHE_REGISTRY }}/${{ inputs.image }}:build-cache
cache-to: type=registry,mode=max,ref=${{ env.CACHE_REGISTRY }}/${{ inputs.image }}:build-cache
target: ${{ inputs.target }}
tags: ${{ env.REGISTRY }}/${{ inputs.image }}:${{ env.PHRASEANET_DOCKER_TAG }}
tags: |
${{ env.DEFAULT_REGISTRY }}/${{ inputs.image }}:${{ env.PHRASEANET_DOCKER_TAG }}
${{ env.ECR_REGISTRY }}/${{ inputs.image }}:${{ env.PHRASEANET_DOCKER_TAG }}
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
context: .
file: ./Dockerfile
target: phraseanet-setup
secrets: inherit

build-phraseanet-nginx:
name: 'build phraseanet-nginx'
Expand All @@ -30,6 +31,7 @@ jobs:
context: .
file: ./Dockerfile
target: phraseanet-nginx
secrets: inherit

build-phraseanet-fpm:
name: 'build phraseanet-fpm'
Expand All @@ -39,6 +41,7 @@ jobs:
context: .
file: ./Dockerfile
target: phraseanet-fpm
secrets: inherit

build-phraseanet-worker:
name: 'build phraseanet-worker'
Expand All @@ -48,6 +51,7 @@ jobs:
context: .
file: ./Dockerfile
target: phraseanet-worker
secrets: inherit

build-phraseanet-db:
name: 'build phraseanet-db'
Expand All @@ -57,6 +61,7 @@ jobs:
context: ./docker/db
file: ./docker/db/Dockerfile
target: ''
secrets: inherit

build-phraseanet-elasticsearch:
name: 'build phraseanet-elasticsearch'
Expand All @@ -66,6 +71,7 @@ jobs:
context: ./docker/elasticsearch
file: ./docker/elasticsearch/Dockerfile
target: ''
secrets: inherit


test:
Expand All @@ -83,31 +89,38 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get tag name
if: github.event_name != 'pull_request'
shell: bash
run: echo "PHRASEANET_DOCKER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV

- name: install
run: |
PHRASEANET_DOCKER_REGISTRY=${{ env.REGISTRY }} PHRASEANET_DOCKER_TAG=${{ env.PHRASEANET_DOCKER_TAG }} docker compose pull
PHRASEANET_DOCKER_REGISTRY=${{ env.REGISTRY }} PHRASEANET_DOCKER_TAG=${{ env.PHRASEANET_DOCKER_TAG }} docker compose up -d
- name: init tools test
run: |
docker compose exec -T -e PHRASEANET_BASE_URL=http://127.0.0.1 phraseanet docker/phraseanet/setup/init-test-install.sh
- name: test exclude-group legacy
run: |
docker compose exec -T phraseanet bin/console system:clear-cache
docker compose exec -T phraseanet php -d memory_limit=-1 vendor/phpunit/phpunit/phpunit --exclude-group legacy
- name: test group legacy and exclude-group web
run: |
docker compose exec -T phraseanet bin/console system:clear-cache
docker compose exec -T phraseanet php -d memory_limit=-1 vendor/phpunit/phpunit/phpunit --group legacy --exclude-group web
- name: test group web
run: |
docker compose exec -T phraseanet bin/console system:clear-cache
Expand Down

0 comments on commit 85da4df

Please sign in to comment.