1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-23 12:37:07 +00:00

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
This commit is contained in:
James Hillyerd
2016-02-22 22:39:14 -08:00
parent 9fafbf73d0
commit f996fa2ae7
6 changed files with 116 additions and 17 deletions

View File

@@ -4,9 +4,14 @@
set -eo pipefail
installdir="${INBUCKET_HOME}"
srcdir="${INBUCKET_SRC}"
installdir="$INBUCKET_HOME"
srcdir="$INBUCKET_SRC"
bindir="$installdir/bin"
defaultsdir="$installdir/defaults"
contextdir="/con/context"
echo "### Installing OS Build Dependencies"
apk add --no-cache --virtual .build-deps git
# Setup
export GOBIN="$bindir"
@@ -16,7 +21,7 @@ go clean
# Build
echo "### Fetching Dependencies"
go get -d -t -v ./...
go get -t -v ./...
echo "### Testing Inbucket"
go test ./...
@@ -25,9 +30,19 @@ echo "### Building Inbucket"
go build -o inbucket -ldflags "-X 'main.BUILDDATE=$builddate'" -v .
echo "### Installing Inbucket"
set -x
mkdir -p "$bindir"
mkdir -p "/etc/opt"
mv inbucket "$bindir"
install etc/docker/inbucket.conf /etc/opt/inbucket.conf
install etc/docker/greeting.html /etc/opt/inbucket-greeting.html
install inbucket "$bindir"
mkdir -p "$contextdir"
install etc/docker/defaults/start-inbucket.sh "$contextdir"
cp -r themes "$installdir/"
mkdir -p "$defaultsdir"
cp etc/docker/defaults/inbucket.conf "$defaultsdir"
cp etc/docker/defaults/greeting.html "$defaultsdir"
set +x
echo "### Removing OS Build Dependencies"
apk del .build-deps
echo "### Removing $GOPATH"
rm -rf "$GOPATH"