Skip to content

Commit

Permalink
Include pre-commit script inside docker images, add comment separatin…
Browse files Browse the repository at this point in the history
…g scripts and build, include -+e to script
  • Loading branch information
bugraoz93 committed Nov 16, 2024
1 parent 8be632c commit b836fda
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,44 @@ while echo "Running"; do
done
EOF


# The content below is automatically copied from scripts/docker/install_yarn_dependencies_from_branch_tip.sh
COPY <<"EOF" /install_yarn_dependencies_from_branch_tip.sh
#!/usr/bin/env bash

. "$( dirname "${BASH_SOURCE[0]}" )/common.sh"

: "${AIRFLOW_REPO:?Should be set}"
: "${AIRFLOW_BRANCH:?Should be set}"
: "${AIRFLOW_SOURCES:?Should be set}"

function install_yarn_dependencies_from_branch_tip() {
echo
echo "${COLOR_BLUE}Installing Yarn dependencies from ${AIRFLOW_BRANCH}. It is used to cache dependencies${COLOR_RESET}"
echo
local TEMP_AIRFLOW_DIR
TEMP_AIRFLOW_DIR=$(mktemp -d)
# Download the source code from the specified branch
set +e
set -x
curl -fsSL "https://github.com/${AIRFLOW_REPO}/archive/${AIRFLOW_BRANCH}.tar.gz" | \
tar xz -C "${TEMP_AIRFLOW_DIR}" --strip 1
# Install Yarn dependencies
cd "${TEMP_AIRFLOW_DIR}/airflow/www"
yarn install --frozen-lockfile
set +x
set -e
echo "${COLOR_BLUE}Yarn dependencies installed successfully${COLOR_RESET}"
# Clean up
rm -rf "${TEMP_AIRFLOW_DIR}"
}

common::get_colors

install_yarn_dependencies_from_branch_tip
EOF


##############################################################################################
# This is the build image where we build all dependencies
##############################################################################################
Expand Down
40 changes: 40 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,46 @@ COPY <<"EOF" /entrypoint_exec.sh
exec /bin/bash "${@}"
EOF


# The content below is automatically copied from scripts/docker/install_yarn_dependencies_from_branch_tip.sh
COPY <<"EOF" /install_yarn_dependencies_from_branch_tip.sh
#!/usr/bin/env bash

. "$( dirname "${BASH_SOURCE[0]}" )/common.sh"

: "${AIRFLOW_REPO:?Should be set}"
: "${AIRFLOW_BRANCH:?Should be set}"
: "${AIRFLOW_SOURCES:?Should be set}"

function install_yarn_dependencies_from_branch_tip() {
echo
echo "${COLOR_BLUE}Installing Yarn dependencies from ${AIRFLOW_BRANCH}. It is used to cache dependencies${COLOR_RESET}"
echo
local TEMP_AIRFLOW_DIR
TEMP_AIRFLOW_DIR=$(mktemp -d)
# Download the source code from the specified branch
set +e
set -x
curl -fsSL "https://github.com/${AIRFLOW_REPO}/archive/${AIRFLOW_BRANCH}.tar.gz" | \
tar xz -C "${TEMP_AIRFLOW_DIR}" --strip 1
# Install Yarn dependencies
cd "${TEMP_AIRFLOW_DIR}/airflow/www"
yarn install --frozen-lockfile
set +x
set -e
echo "${COLOR_BLUE}Yarn dependencies installed successfully${COLOR_RESET}"
# Clean up
rm -rf "${TEMP_AIRFLOW_DIR}"
}

common::get_colors

install_yarn_dependencies_from_branch_tip
EOF

##############################################################################################
# This is the build image
##############################################################################################
FROM ${PYTHON_BASE_IMAGE} as main

# Nolog bash flag is currently ignored - but you can replace it with other flags (for example
Expand Down
2 changes: 2 additions & 0 deletions scripts/docker/install_yarn_dependencies_from_branch_tip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ function install_yarn_dependencies_from_branch_tip() {
local TEMP_AIRFLOW_DIR
TEMP_AIRFLOW_DIR=$(mktemp -d)
# Download the source code from the specified branch
set +e
set -x
curl -fsSL "https://github.com/${AIRFLOW_REPO}/archive/${AIRFLOW_BRANCH}.tar.gz" | \
tar xz -C "${TEMP_AIRFLOW_DIR}" --strip 1
# Install Yarn dependencies
cd "${TEMP_AIRFLOW_DIR}/airflow/www"
yarn install --frozen-lockfile
set +x
set -e
echo "${COLOR_BLUE}Yarn dependencies installed successfully${COLOR_RESET}"
# Clean up
rm -rf "${TEMP_AIRFLOW_DIR}"
Expand Down

0 comments on commit b836fda

Please sign in to comment.