Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Better local building #16586

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
node_modules/
dist/
scripts/ci/
/cache*
/cache*
cache/
.git/
log/
*.log
16 changes: 15 additions & 1 deletion scripts/ci/_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
set -euo pipefail
if [[ -n "${DEBUG:-}" || -n "${CI:-}" ]]; then set -x; fi

# Required environment variables
REQUIRED_ENV=(APP DOCKER_TAG)
for e in "${REQUIRED_ENV[@]}"; do
if [[ -z "${!e:-}" ]]; then
echo "ERROR: $e is not set" >&2
echo "Required env vars: ${REQUIRED_ENV[*]}" >&2
exit 1
fi
done

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

# shellcheck disable=SC1091
Expand All @@ -16,6 +26,8 @@ ACTION=${3:-docker_build}
PLAYWRIGHT_VERSION="$(yarn info --json @playwright/test | jq -r '.children.Version')"
CONTAINER_BUILDER=${CONTAINER_BUILDER:-docker}
DOCKER_LOCAL_CACHE="${DOCKER_LOCAL_CACHE:-true}"
NODE_IMAGE_TAG="${NODE_IMAGE_TAG:-$(cd "$DIR" && ../../scripts/ci/get-node-version.mjs)}"
DOCKER_REGISTRY=${DOCKER_REGISTRY:-localhost}

BUILD_ARGS=()

Expand All @@ -29,8 +41,9 @@ mkargs() {
--build-arg="APP=${APP}"
--build-arg="APP_HOME=${APP_HOME}"
--build-arg="APP_DIST_HOME=${APP_DIST_HOME}"
-t "${DOCKER_REGISTRY}""${APP}":"${DOCKER_TAG}"
-t "${DOCKER_REGISTRY}/${APP}:${DOCKER_TAG}"
--build-arg="PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}"
--build-arg="NODE_IMAGE_TAG=${NODE_IMAGE_TAG}"
)
for extra_arg in ${EXTRA_DOCKER_BUILD_ARGS:-}; do
BUILD_ARGS+=("$extra_arg")
Expand All @@ -43,6 +56,7 @@ mkargs() {

container_build() {
$CONTAINER_BUILDER buildx build "${BUILD_ARGS[@]}" "$PROJECT_ROOT"
echo "Successfully built ${DOCKER_REGISTRY}/${APP}:${DOCKER_TAG}" >&2
}

docker_build() {
Expand Down
Loading