Last active
October 6, 2016 10:15
-
-
Save HokieGeek/a951027e1c41b022e4c68d18f4dbb320 to your computer and use it in GitHub Desktop.
Sets up a dev environment for a small project
This file contains hidden or 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
version: '2' | |
services: | |
biologist-web: | |
build: | |
context: ~/src/web/biologist-web | |
dockerfile: Dockerfile | |
ports: | |
- "8080:8080" | |
entrypoint: | |
- python3 | |
- -m | |
- http.server | |
command: "8080" | |
depends_on: | |
- biologistd | |
biologistd: | |
build: | |
context: ~/go/src/github.com/hokiegeek | |
dockerfile: Dockerfile-life | |
ports: | |
- "8081:8081" | |
entrypoint: | |
- biologistd | |
command: ["--port", "8081"] | |
logging: | |
driver: json-file |
This file contains hidden or 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
FROM golang:latest | |
RUN mkdir -p /go/src/github.com/hokiegeek && cd /go/src/github.com/hokiegeek && mkdir -p life biologist biologistd | |
ADD life /go/src/github.com/hokiegeek/life | |
ADD biologist /go/src/github.com/hokiegeek/biologist | |
ADD biologistd /go/src/github.com/hokiegeek/biologistd | |
RUN go install github.com/hokiegeek/biologistd |
This file contains hidden or 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 | |
here=$(cd ${0%/*}; pwd) | |
t=$(mktemp) | |
cat << 'EOF' > $t | |
declare -a life_dirs=($GOPATH/src/github.com/hokiegeek/life | |
$GOPATH/src/github.com/hokiegeek/biologist | |
$GOPATH/src/github.com/hokiegeek/biologistd | |
$HOME/src/web/biologist-web) | |
life-each() { | |
for r in "${life_dirs[@]}"; do | |
echo -e "\033[33m<$(basename $r)>\033[0m" | |
pushd $r &>/dev/null | |
eval $@ | |
popd &>/dev/null | |
done | |
} | |
life-build() { | |
tmux new-window -d -n "Rebuilding containers" \ | |
-c $HOME/src/life-dev \ | |
"docker-compose down && docker-compose up --build -d && \ | |
tmux rename-window -t 'Rebuilding containers' logs && \ | |
clear; docker logs --follow lifedev_biologistd_1 | tee /tmp/lifed.log" | |
} | |
life-exit() { | |
kill $(cat /tmp/surf.pid) || pkill surf | |
rm -rf $GOPATH/src/github.com/hokiegeek/Dockerfile-life | |
tmux new-window -d -n "Stopping containers" -c $HOME/src/life-dev docker-compose down | |
tmux send-keys -t web-src ":wqa" C-m | |
tmux send-keys -t life-src ":wqa" C-m | |
tmux kill-window -t life | |
} | |
alias life-go='cd $GOPATH/src/github.com/hokiegeek' | |
alias life-web='cd $HOME/src/web/biologist-web' | |
alias life-log='docker logs --follow lifedev_biologistd_1' | |
EOF | |
# Split of go and web directories | |
tmux new-window -n life -c $GOPATH/src/github.com/hokiegeek | |
tmux split-window -d -c $HOME/src/web/biologist-web | |
# Display git status on both directory splits | |
tmux send-keys -t:.0 ". ${t}; clear" C-m \; send-keys -t:.1 ". ${t}; clear" C-m | |
tmux send-keys -t:.0 "life-each git st" C-m | |
# life source files | |
tmux new-window -d -n life-src -c $GOPATH/src/github.com/hokiegeek "vim biologist/*.go biologistd/*.go life/*.go" | |
# web source files | |
tmux new-window -d -n web-src -c $HOME/src/web/biologist-web \ | |
vim index.html js/analysis.js css/analysis.css \ | |
-c "silent! bufdo set nofoldenable" \ | |
-c "buffer analysis.js" \ | |
-c "filetype detect" \ | |
-c "vsplit" \ | |
-c "buffer analysis.css" \ | |
-c "vertical res 40" \ | |
-c "wincmd h" | |
# Bring up the services and tail the logs | |
## Copy the dockerfile to use when creating the images | |
cp ${here}/Dockerfile-life $GOPATH/src/github.com/hokiegeek | |
# tmux new-window -d -n "Starting containers" -c ${here} docker-compose up --build -d | |
tmux new-window -d -n "Starting containers" -c ${here} \ | |
"docker-compose up --build -d && \ | |
tmux rename-window -t 'Starting containers' logs && \ | |
surf http://0.0.0.0:8080 >/dev/null 2>&1 & | |
echo $! > /tmp/surf.pid | |
clear; docker logs --follow lifedev_biologistd_1 | tee /tmp/lifed.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment