This commit is contained in:
+7
-11
@@ -6,21 +6,17 @@ steps:
|
|||||||
deploy:
|
deploy:
|
||||||
image: docker:cli
|
image: docker:cli
|
||||||
volumes:
|
volumes:
|
||||||
- /root/lab:/host-lab
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
set -eu
|
set -eu
|
||||||
CONTAINER_ID="$(docker ps --filter publish=8091 --format '{{.ID}}' | head -n 1)"
|
CONTAINER_ID="$(docker ps --filter publish=8091 --format '{{.ID}}' | head -n 1)"
|
||||||
test -n "$CONTAINER_ID" || { echo "No running portfolio container found on port 8091"; exit 1; }
|
test -n "$CONTAINER_ID" || { echo "No running portfolio container found on port 8091"; exit 1; }
|
||||||
HOST_SITE="$(docker inspect "$CONTAINER_ID" --format '{{range .Mounts}}{{if eq .Destination "/usr/share/nginx/html"}}{{.Source}}{{end}}{{end}}')"
|
docker exec "$CONTAINER_ID" sh -c "grep -q 'Keith Casko' /usr/share/nginx/html/index.html" || { echo "Port 8091 container does not look like casko.dev"; exit 1; }
|
||||||
test -n "$HOST_SITE" || { echo "Portfolio container has no /usr/share/nginx/html bind mount"; exit 1; }
|
docker cp index.html "$CONTAINER_ID":/usr/share/nginx/html/index.html
|
||||||
SITE_INDEX="$(grep -rl -m1 --include='index.html' 'Keith Casko' /host-lab 2>/dev/null | head -n 1)"
|
docker cp homelab.html "$CONTAINER_ID":/usr/share/nginx/html/homelab.html
|
||||||
test -n "$SITE_INDEX" || { echo "Could not locate casko.dev index.html under /root/lab"; exit 1; }
|
docker cp css "$CONTAINER_ID":/usr/share/nginx/html/
|
||||||
TARGET="$(dirname "$SITE_INDEX")"
|
docker cp js "$CONTAINER_ID":/usr/share/nginx/html/
|
||||||
echo "Portfolio container: $CONTAINER_ID"
|
docker cp assets "$CONTAINER_ID":/usr/share/nginx/html/
|
||||||
echo "Reported host mount: $HOST_SITE"
|
|
||||||
echo "Resolved live site: $TARGET"
|
|
||||||
cp -a index.html homelab.html css js assets "$TARGET/"
|
|
||||||
docker restart "$CONTAINER_ID"
|
docker restart "$CONTAINER_ID"
|
||||||
echo "Deployed commit $CI_COMMIT_SHA to $HOST_SITE"
|
echo "Deployed commit $CI_COMMIT_SHA to casko.dev container $CONTAINER_ID"
|
||||||
Reference in New Issue
Block a user