1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00
Files
go-inbucket/etc/docker/docker-run.sh
James Hillyerd f996fa2ae7 Docker best practices
- Install and remove OS and Go build deps in a single layer
- Use COPY instead of ADD
- WORKDIR now resolves ENV variables, use one
- Use VOLUMES for configuration and datastore
- Added launcher script start-inbucket.sh
- Made docker-run.sh more powerful
2016-02-23 22:09:39 -08:00

63 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# docker-run.sh
# description: Launch Inbucket's docker image
# Docker Image Tag
IMAGE="jhillyerd/inbucket"
# Ports exposed on host:
PORT_HTTP=9000
PORT_SMTP=2500
PORT_POP3=1100
# Volumes exposed on host:
VOL_CONFIG="/tmp/inbucket/config"
VOL_DATA="/tmp/inbucket/data"
set -eo pipefail
main() {
local run_opts=""
for arg in $*; do
case "$arg" in
-h)
usage
exit
;;
-r)
reset
;;
-d)
run_opts="$run_opts -d"
;;
*)
usage
exit 1
;;
esac
done
docker run $run_opts \
-p $PORT_HTTP:10080 \
-p $PORT_SMTP:10025 \
-p $PORT_POP3:10110 \
-v "$VOL_CONFIG:/con/configuration" \
-v "$VOL_DATA:/con/data" \
"$IMAGE"
}
usage() {
echo "$0 [options]" 2>&1
echo " -d detach - detach and print container ID" 2>&1
echo " -r reset - purge config and data before startup" 2>&1
echo " -h help - print this message" 2>&1
}
reset() {
/bin/rm -rf "$VOL_CONFIG"
/bin/rm -rf "$VOL_DATA"
}
main $*