From 0001c93792d3e9f08a4653915a879a32c7c7d7f6 Mon Sep 17 00:00:00 2001 From: Ari Date: Fri, 27 May 2022 13:37:43 -0400 Subject: [PATCH] speeding up build times --- Dockerfile | 18 ++++++++++-------- Makefile | 12 ++++-------- docker/bin/build.sh | 28 ++++++++++++++++++++++++++++ docker/bin/prep.sh | 19 +++++++++++++++++++ 4 files changed, 61 insertions(+), 16 deletions(-) create mode 100755 docker/bin/build.sh create mode 100755 docker/bin/prep.sh diff --git a/Dockerfile b/Dockerfile index d7d5531..643c1f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,21 +19,23 @@ RUN apk add --no-cache \ npm \ build-base \ python3-dev -RUN pip install -U wheel setuptools pip && \ - npm i -g yarn + +# <--- Scripts --> +COPY docker/bin /app/bin + +# <--- PREP --> +RUN /app/bin/prep.sh # <--- Python Dependencies --> COPY api/setup.py /app/setup.py -RUN pip install . /app # <--- Webapp Build --> COPY webapp/ /app/web-builder RUN cd /app/web-builder && \ - echo "REACT_APP_BUILD_VERSION=${BUILD_VERSION}" > /app/web-builder/.env.production && \ - yarn && \ - yarn build && \ - cp -r /app/web-builder/build /app/web && \ - rm -rf /app/web-builder + echo "REACT_APP_BUILD_VERSION=${BUILD_VERSION}" > /app/web-builder/.env.production + +# <--- BUILD --> +RUN /app/bin/build.sh /app /app/web-builder # <--- Api Code --> COPY api/src /app/src diff --git a/Makefile b/Makefile index 07f885d..2a6dbf5 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,18 @@ DC=docker-compose -f docker-compose.build.yaml -f docker-compose.test.yaml build: $(DC) build -push: - $(DC) push - -local_run: +run: $(MAKE) build $(DC) up -d sleep 1 $(DC) ps -local_logs: +logs: $(DC) logs -f -local_ps: +ps: $(DC) ps - -local_stop: +stop: $(DC) stop diff --git a/docker/bin/build.sh b/docker/bin/build.sh new file mode 100755 index 0000000..e8e373e --- /dev/null +++ b/docker/bin/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +api_location=${1} +web_location=${2} + +function install_yarn() { + pushd $web_location + yarn + yarn build + cp -r $web_location/build $api_location/web + popd +} + +function install_py() { + pushd $api_location + pip install . $api_location + popd +} + +declare -i err=0 werr=0 +install_py & +install_yarn & +while wait -fn || werr=$?; ((werr != 127)); do + err=$werr +done + +echo "DONE BUILD" \ No newline at end of file diff --git a/docker/bin/prep.sh b/docker/bin/prep.sh new file mode 100755 index 0000000..1a871e0 --- /dev/null +++ b/docker/bin/prep.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +function prep_yarn() { + npm i -g yarn +} + +function prep_py() { + pip install -U wheel setuptools pip +} + +declare -i err=0 werr=0 +prep_py & +prep_yarn & +while wait -fn || werr=$?; ((werr != 127)); do + err=$werr +done + +echo "DONE PREP" \ No newline at end of file