devops: switch docker publishing to a bash script (#3704)

It turns out Github Actions have docker pre-installed.

This patch unifies the codepaths that we use to build docker image
locally and to publish it from CI.

As a result, there's no extra `--prepare-context` argument in
`//docs/docker/build.sh` that was used solely on CI.

References #2926
This commit is contained in:
Andrey Lushnikov 2020-09-01 11:33:19 -07:00 committed by GitHub
parent db9b8a003f
commit ef5c87ccea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 27 deletions

View file

@ -21,15 +21,16 @@ jobs:
node-version: 10.15 node-version: 10.15
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: ./docs/docker/build.sh --prepare-context - name: login & publish to docker
- uses: docker/build-push-action@v1 run: |
with: # login to docker
username: playwright docker login --username playwright --password ${{ secrets.DOCKER_PASSWORD }} playwright.azurecr.io
password: ${{ secrets.DOCKER_PASSWORD }} # build docker image
registry: playwright.azurecr.io ./docs/docker/build.sh
repository: public/playwright # tag image accordingly
path: docs/docker/ docker tag playwright:localbuild public/playwright:next
dockerfile: docs/docker/Dockerfile.bionic docker tag playwright:localbuild public/playwright:sha-$(git rev-parse HEAD)
tags: next docker rmi playwright:localbuild
tag_with_sha: true # push image to registry
docker push public/playwright:next

View file

@ -3,7 +3,7 @@ set -e
set +x set +x
if [[ ($1 == '--help') || ($1 == '-h') ]]; then if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [--prepare-only]" echo "usage: $(basename $0)"
echo echo
echo "Build Playwright docker image and tag it as 'playwright:localbuild'." echo "Build Playwright docker image and tag it as 'playwright:localbuild'."
echo "Once image is built, you can run it with" echo "Once image is built, you can run it with"
@ -12,22 +12,12 @@ if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "" echo ""
echo "NOTE: this requires on Playwright dependencies to be installed with 'npm install'" echo "NOTE: this requires on Playwright dependencies to be installed with 'npm install'"
echo " and Playwright itself being built with 'npm run build'" echo " and Playwright itself being built with 'npm run build'"
echo
echo " --prepare-context prepare docker context and skip building."
echo " This is to defer building & publishing to Docker Github Action."
echo "" echo ""
exit 0 exit 0
fi fi
PREPARE_CONTEXT_ONLY=""
if [[ $1 == "--prepare-context" ]]; then
PREPARE_CONTEXT_ONLY="1"
fi
function cleanup() { function cleanup() {
if [[ -z "${PREPARE_CONTEXT_ONLY}" ]]; then rm -f "playwright.tar.gz"
rm -f "playwright.tar.gz"
fi
} }
trap "cleanup; cd $(pwd -P)" EXIT trap "cleanup; cd $(pwd -P)" EXIT
@ -37,8 +27,4 @@ cd "$(dirname "$0")"
# image. # image.
node ../../packages/build_package.js playwright ./playwright.tar.gz node ../../packages/build_package.js playwright ./playwright.tar.gz
if [[ -n "${PREPARE_CONTEXT_ONLY}" ]]; then
exit 0
fi
docker build -t "playwright:localbuild" -f Dockerfile.bionic . docker build -t "playwright:localbuild" -f Dockerfile.bionic .