Created
November 16, 2021 01:54
-
-
Save zackexplosion/7af679815d6bc8506c437dc7bc022837 to your computer and use it in GitHub Desktop.
docker build and deploy to nas
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
IMAGE_NAME=your-image-name | |
[email protected] | |
ARCHIVE_FILE_NAME=archive.tar | |
REMOTE_PATH=/a/remote/path | |
REMOTE_PORT=22 | |
PORTMAP=1111:1111 | |
rm $ARCHIVE_FILE_NAME | |
docker rmi $IMAGE_NAME | |
docker build . -t $IMAGE_NAME | |
docker save $IMAGE_NAME > $ARCHIVE_FILE_NAME | |
scp -P $REMOTE_PORT $ARCHIVE_FILE_NAME $NAS_URI:$REMOTE_PATH | |
set -x; | |
ssh -p $REMOTE_PORT $NAS_URI "/usr/local/bin/docker rm \$(/usr/local/bin/docker stop \$(/usr/local/bin/docker ps -a -q --filter ancestor=$IMAGE_NAME))" | |
set +x; | |
ssh -p $REMOTE_PORT $NAS_URI "/usr/local/bin/docker rmi $IMAGE_NAME" | |
ssh -p $REMOTE_PORT $NAS_URI "/usr/local/bin/docker load < $REMOTE_PATH/$ARCHIVE_FILE_NAME" | |
ssh -p $REMOTE_PORT $NAS_URI "/usr/local/bin/docker run -d -p $PORTMAP $IMAGE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment