This is an automated email from the ASF dual-hosted git repository. tomaz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/libcloud-site.git
commit 68f348d6c7daff03bcd536cd8468fff732fb9789 Author: Tomaz Muraus <[email protected]> AuthorDate: Wed Mar 30 21:57:33 2022 +0200 Update readme, scripts to support using pre-built docker images for faster development. --- README.md | 21 +++++++++++++++++++-- scripts/docker-build-site.sh | 17 +++++++++++++++-- scripts/docker-run-dev-server.sh | 16 ++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d27986..2052008 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,7 @@ node_modules/.bin/grunt lint ## Running Local Development Server ```bash -docker-run-dev-server.sh -./scripts/run-dev-server.sh +./scripts/docker-run-dev-server.sh # Non-Docker versions #./scripts/run-dev-server.sh ``` @@ -72,6 +71,24 @@ This will start Docker container with local development server listening on port git push origin <branch> ``` +## Note on pre-built Docker images + +To speed up local development, we offer pre-built version of theDocker image +used for local development - +https://github.com/apache/libcloud-site/pkgs/container/libcloud-site-dev. + +This image is used by default when using ``./scripts/docker-*.sh`` scripts. + +If for some reason you want to use locally built Docker image (e.g. you have +made changes changes to the Dockerfile, Gemfile or similar), you can do that by +setting ``USE_LOCAL_DOCKER_IMAGE=1`` environment variable when using those scripts. + +For example: + +```bash +USE_LOCAL_DOCKER_IMAGE=1 ./scripts/docker-run-dev-server.sh +``` + ## Branch Layout * [master](https://github.com/apache/libcloud-site/tree/master) - Contains website source code without the generated content. diff --git a/scripts/docker-build-site.sh b/scripts/docker-build-site.sh index 73e67a3..ed2e233 100755 --- a/scripts/docker-build-site.sh +++ b/scripts/docker-build-site.sh @@ -15,9 +15,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -IMAGE_NAME="libcloud-site-dev" +# TODO: Refactor in common file to reduce duplication +USE_LOCAL_DOCKER_IMAGE="${USE_LOCAL_DOCKER_IMAGE:-"0"}" + +IMAGE_NAME_LOCAL="libcloud-site-dev" +IMAGE_NAME_REMOTE="ghcr.io/apache/libcloud-site-dev:latest" + +if [ "${USE_LOCAL_DOCKER_IMAGE}" = "1" ]; then + echo "Will use and build local Docker image" + IMAGE_NAME="${IMAGE_NAME_LOCAL}" + + docker build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" -f Dockerfile -t "${IMAGE_NAME}" . --progress=plain +else + echo "Will use pre-built Docker image from ghcr.io" + IMAGE_NAME="${IMAGE_NAME_REMOTE}" +fi -docker build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" -f Dockerfile -t "${IMAGE_NAME}" . --progress=plain docker run --rm -v "$(pwd)":/home/jekyll/site -it "${IMAGE_NAME}" bash -l -c "pushd source; bundle exec jekyll build; popd;" #docker run --rm -v "$(pwd)":/home/jekyll/site -it "${IMAGE_NAME}" bash -l -c "pushd source; bundle exec jekyll build; popd; ./scripts/optimize-images.sh" diff --git a/scripts/docker-run-dev-server.sh b/scripts/docker-run-dev-server.sh index 91066b8..40ceeb4 100755 --- a/scripts/docker-run-dev-server.sh +++ b/scripts/docker-run-dev-server.sh @@ -15,7 +15,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -IMAGE_NAME="libcloud-site-dev" +USE_LOCAL_DOCKER_IMAGE="${USE_LOCAL_DOCKER_IMAGE:-"0"}" + +IMAGE_NAME_LOCAL="libcloud-site-dev" +IMAGE_NAME_REMOTE="ghcr.io/apache/libcloud-site-dev:latest" + +if [ "${USE_LOCAL_DOCKER_IMAGE}" = "1" ]; then + echo "Will use and build local Docker image" + IMAGE_NAME="${IMAGE_NAME_LOCAL}" + + docker build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" -f Dockerfile -t "${IMAGE_NAME}" . --progress=plain +else + echo "Will use pre-built Docker image from ghcr.io" + IMAGE_NAME="${IMAGE_NAME_REMOTE}" +fi -docker build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" -f Dockerfile -t "${IMAGE_NAME}" . --progress=plain docker run -p 4000:4000 --rm -v "$(pwd)":/home/jekyll/site -it "${IMAGE_NAME}" bash -c -l 'cd source ; bundle exec jekyll serve --watch --drafts --trace --force_polling -H 0.0.0.0 -P 4000'
