Skip to content

Instantly share code, notes, and snippets.

@evzpav
Last active March 31, 2019 19:46
Show Gist options
  • Save evzpav/60e895b509c00e0b44c1921030c30f97 to your computer and use it in GitHub Desktop.
Save evzpav/60e895b509c00e0b44c1921030c30f97 to your computer and use it in GitHub Desktop.
Add all configs fo golang project to run on dokku. Create Procfile, up_dokku script, and add metadata to Gopkg.toml
#!/bin/bash
#run dep
if [ ! -f "Gopkg.toml" ]; then
echo "running go dep"
go get -u github.com/golang/dep/cmd/dep
dep init
dep ensure
fi
DIR=$(pwd)
#assumes project is inside a folder on $GOPATH/src/
PACKAGE_PATH=${DIR/$GOPATH\/src\/""}
PROJECT_NAME=${PACKAGE_PATH##*/}
#generate Procfile
echo "web: $PROJECT_NAME" > Procfile
isInFile=$(cat Gopkg.toml | grep -c "metadata.heroku")
if [ $isInFile -eq 0 ]; then
echo "Added metadata to Gopkg.toml"
# add metadata to Gopkg.toml
echo -e "\n[metadata.heroku]\n\troot-package = \"$PACKAGE_PATH\"\n\tgo-version = \"1.11\"\n\tinstall = [ \"./...\" ]\n\tensure = true" >> Gopkg.toml
fi
# create deploy script
echo "
#!/bin/bash
git add .
git commit -m \"up to dokku\"
git push dokku master " > up_dokku.sh
chmod 700 up_dokku.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment