From 766ee4072ccf6adc3d867472e49c50afb23bd516 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Mon, 4 Nov 2024 19:28:06 +0100 Subject: [PATCH] Try to reduce the feedback loop time with local docker --- Dockerfile | 2 +- package.json | 4 +++- scripts/docker-build.sh | 10 ++++++++++ scripts/docker-buildargs.sh | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 scripts/docker-build.sh create mode 100755 scripts/docker-buildargs.sh diff --git a/Dockerfile b/Dockerfile index 0d5c4b8b9..eb12b3185 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,7 +84,7 @@ RUN mv robots-disallow.txt ./static/robots.txt RUN npm run build:graphql # Expose the app port -EXPOSE 8080 +EXPOSE 4173 # Build project RUN npm run build diff --git a/package.json b/package.json index 1883bcfdd..bde46c078 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "prepare": "husky install", "postinstall": "./scripts/install-twemoji-assets.sh", "build:graphql": "./scripts/build-gql-types.sh", - "analyze-unused-code": "knip" + "analyze-unused-code": "knip", + "docker:build": "./scripts/docker-build.sh", + "docker:run": "docker run -t -i -p 4173:4173 drips-app" }, "devDependencies": { "@graphql-codegen/cli": "^5.0.2", diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh new file mode 100755 index 000000000..356df07ab --- /dev/null +++ b/scripts/docker-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# cd to the scripts directory +cd "$(dirname "$(realpath -- "$0")")" +# print the current directory +pwd +# echo the command we're about to run +echo $(./docker-buildargs.sh ../.env) +# run the command +docker build $(./docker-buildargs.sh ../.env) ../. -t drips-app --platform=linux/amd64 \ No newline at end of file diff --git a/scripts/docker-buildargs.sh b/scripts/docker-buildargs.sh new file mode 100755 index 000000000..d14ef2f0f --- /dev/null +++ b/scripts/docker-buildargs.sh @@ -0,0 +1,4 @@ +# !/bin/bash + +# Given an env file, remove blank lines and comments and turn those lines into build args. +grep -v -e '^[[:space:]]*$' -e '^#' $@ | awk '{ sub ("\\\\$", " "); printf " --build-arg %s", $0 } END { print "" }' \ No newline at end of file