Last active
November 24, 2019 03:46
-
-
Save chocolatkey/7ef1bd8807b5703ef7c6441e1134a4fb to your computer and use it in GitHub Desktop.
newbie podman deploy script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# chocolatkey 2019-10-05 - 2019-11-23 | |
set +e | |
PD_POD_NAME="my-pod-name" | |
PD_POD_PORT="9000" | |
PD_CONTAINER_NAME="my-container-name" | |
PD_PACKAGE_URL="docker.pkg.github.com/myuser/myrepo/mydockerpackage" | |
if [ "$1" == "" ]; then | |
echo "PodDeployer 9000" | |
echo "Usage: $0 <release tag>" | |
exit 1 | |
fi | |
PD_REMOTE_IMG="$PD_PACKAGE_URL:$1" | |
echo "UPDATING code with master branch from git" | |
if ! git pull origin master; then | |
echo "Failed UPDATING" | |
exit 1 | |
fi | |
# TODO config | |
echo "BUILDING image with tag $1" | |
buildah bud -t "$PD_REMOTE_IMG" . && \ | |
echo "PUSHING image with tag $1" && \ | |
buildah push "$PD_REMOTE_IMG" && \ | |
echo "PULLING image with tag $1" && \ | |
podman pull "$PD_REMOTE_IMG" | |
if podman pod exists $PD_POD_NAME; then | |
echo "REMOVING Pod $PD_POD_NAME because it already exists" | |
podman pod stop $PD_POD_NAME | |
podman pod rm -f $PD_POD_NAME | |
#podman play kube pod.yaml | |
fi | |
echo "CREATING pod $PD_POD_NAME" | |
podman pod create --name $PD_POD_NAME -p $PD_POD_PORT | |
echo "RUNNING container with tag $1 in pod $PD_POD_NAME" | |
podman run -d --pod $PD_POD_NAME --name $PD_CONTAINER_NAME --env-file .env "$PD_REMOTE_IMG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment