├── upgrade.sh ├── readme.md └── Dockerfile /upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Download the configuration scripts, unpack and remove the temp file 4 | echo "" 5 | echo "-> Downloading Rancher Stack Configurations" 6 | PROJECT_CONFIG_URL=$RANCHER_URL"/environments/"$RANCHER_STACK_ID"/composeconfig" 7 | curl -s -L -u "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" $PROJECT_CONFIG_URL -o config.zip 8 | unzip config.zip 9 | rm config.zip 10 | 11 | # Do Upgrade 12 | echo "" 13 | echo "-> Updating service $RANCHER_SERVICE_NAME on $RANCHER_STACK_NAME" 14 | rancher-compose -p $RANCHER_STACK_NAME up \ 15 | --force-upgrade --confirm-upgrade --pull \ 16 | -d $RANCHER_SERVICE_NAME 17 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## codecasts/rancher-deployer 2 | 3 | Easily upgrade Rancher services. 4 | 5 | #### Usage 6 | 7 | You can build this image or customize and build your own, to upgrade a service, use it the following way: 8 | 9 | Considering your Stack with ID `1e9` named `myapp-production` running on a environment ID `1a5` 10 | 11 | Under this stack, you want to upgrade a service named `web` 12 | 13 | ``` 14 | 15 | docker run --rm \ 16 | -e RANCHER_URL="http://my-rancher.com:8080/v1/projects/1a5" \ 17 | -e RANCHER_ACCESS_KEY="my_api_key" \ 18 | -e RANCHER_SECRET_KEY="my_api_secret \ 19 | -e RANCHER_STACK_ID="1e9" \ 20 | -e RANCHER_STACK_NAME="myapp-production" \ 21 | -e RANCHER_SERVICE_NAME="web" \ 22 | codecasts/rancher-deployer:latest 23 | ``` 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.4 2 | 3 | MAINTAINER Diego Hernandes 4 | 5 | ENV RANCHER_URL=http://127.0.0.1:8080/v1/projects/1a5 \ 6 | RANCHER_ACCESS_KEY=none \ 7 | RANCHER_SECRET_KEY=none \ 8 | RANCHER_STACK_ID=project \ 9 | RANCHER_STACK_NAME=project \ 10 | RANCHER_SERVICE_NAME=service 11 | 12 | ADD upgrade.sh /root/upgrade.sh 13 | 14 | RUN chmod +x /root/upgrade.sh && \ 15 | apk -U upgrade && \ 16 | apk add --no-cache --update \ 17 | curl \ 18 | unzip \ 19 | tar \ 20 | gzip \ 21 | ca-certificates && \ 22 | update-ca-certificates --fresh && \ 23 | rm -rf /var/cache/apk/* && \ 24 | rm -rf /tmp/* && \ 25 | curl -L \ 26 | https://releases.rancher.com/compose/v0.12.5/rancher-compose-linux-amd64-v0.12.5.tar.gz \ 27 | -o rancher-compose.tar.gz && \ 28 | tar zxvf rancher-compose.tar.gz --strip-components 2 && \ 29 | rm -rf rancher-compose.tar.gz && \ 30 | mv rancher-compose /usr/bin/rancher-compose && \ 31 | chmod +x /usr/bin/rancher-compose 32 | 33 | CMD ["/root/upgrade.sh"] 34 | --------------------------------------------------------------------------------