Skip to content

Commit

Permalink
devops: switch docker publishing to a bash script (#3704)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aslushnikov authored Sep 1, 2020
1 parent db9b8a0 commit ef5c87c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/publish_canary_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ jobs:
node-version: 10.15
- run: npm ci
- run: npm run build
- run: ./docs/docker/build.sh --prepare-context
- uses: docker/build-push-action@v1
with:
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
registry: playwright.azurecr.io
repository: public/playwright
path: docs/docker/
dockerfile: docs/docker/Dockerfile.bionic
tags: next
tag_with_sha: true
- name: login & publish to docker
run: |
# login to docker
docker login --username playwright --password ${{ secrets.DOCKER_PASSWORD }} playwright.azurecr.io
# build docker image
./docs/docker/build.sh
# tag image accordingly
docker tag playwright:localbuild public/playwright:next
docker tag playwright:localbuild public/playwright:sha-$(git rev-parse HEAD)
docker rmi playwright:localbuild
# push image to registry
docker push public/playwright:next
18 changes: 2 additions & 16 deletions docs/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
set +x

if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo "usage: $(basename $0) [--prepare-only]"
echo "usage: $(basename $0)"
echo
echo "Build Playwright docker image and tag it as 'playwright:localbuild'."
echo "Once image is built, you can run it with"
Expand All @@ -12,22 +12,12 @@ if [[ ($1 == '--help') || ($1 == '-h') ]]; then
echo ""
echo "NOTE: this requires on Playwright dependencies to be installed with 'npm install'"
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 ""
exit 0
fi

PREPARE_CONTEXT_ONLY=""
if [[ $1 == "--prepare-context" ]]; then
PREPARE_CONTEXT_ONLY="1"
fi

function cleanup() {
if [[ -z "${PREPARE_CONTEXT_ONLY}" ]]; then
rm -f "playwright.tar.gz"
fi
rm -f "playwright.tar.gz"
}

trap "cleanup; cd $(pwd -P)" EXIT
Expand All @@ -37,8 +27,4 @@ cd "$(dirname "$0")"
# image.
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 .

0 comments on commit ef5c87c

Please sign in to comment.