build(run): add artifact command
Add an `artifact:build` command that will pull the image for a given commit SHA and copy the generated HTML from it onto the local filesystem so that it can be served by Nginx in production.
This commit is contained in:
parent
2d684f26ab
commit
b742b1d8a1
21
run
21
run
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
. .env
|
. .env
|
||||||
|
|
||||||
|
@ -48,8 +48,23 @@ function help {
|
||||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function run-production {
|
function artifact:build {
|
||||||
docker-compose --file docker-compose-production.yaml up --detach --remove-orphans
|
DESTINATION_PATH="${2:-/var/www/oliverdavies.uk}"
|
||||||
|
GIT_COMMIT_HASH=$1
|
||||||
|
|
||||||
|
# Clean up any old containers or files within the artifact directory.
|
||||||
|
rm -fr ${DESTINATION_PATH}/* || true
|
||||||
|
|
||||||
|
docker image pull ghcr.io/opdavies/oliverdavies-uk-web:${GIT_COMMIT_HASH}
|
||||||
|
|
||||||
|
docker container run \
|
||||||
|
--entrypoint sh \
|
||||||
|
--name oliverdavies-uk-web \
|
||||||
|
ghcr.io/opdavies/oliverdavies-uk-web:${GIT_COMMIT_HASH}
|
||||||
|
|
||||||
|
docker container cp oliverdavies-uk-web:/code ${DESTINATION_PATH}
|
||||||
|
|
||||||
|
docker container rm oliverdavies-uk-web
|
||||||
}
|
}
|
||||||
|
|
||||||
function sh {
|
function sh {
|
||||||
|
|
Loading…
Reference in a new issue