- Added an entrypoint script so app could be run in relay mode

- Fixed Dockerfile to only copy in required files so changing the Dockerfile doesn't trigger a recompile :-)
- Added some helper scripts for using Docker
This commit is contained in:
Douglas Muth 2019-07-14 21:35:31 -04:00
parent ab215af53e
commit d34477f5f6
4 changed files with 59 additions and 2 deletions

View file

@ -4,7 +4,11 @@
FROM golang:1.12-alpine as builder
RUN apk add --no-cache git ca-certificates # add deps here (like make) if needed
WORKDIR /go/hostyoself
COPY . .
COPY main.go .
COPY go.mod .
COPY pkg pkg
COPY static static
COPY templates templates
# any pre-requisities to building should be added here
RUN go generate -v
RUN go build -v
@ -15,6 +19,8 @@ RUN go build -v
FROM alpine:latest
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/hostyoself/hostyoself /hostyoself
COPY bin/entrypoint.sh /entrypoint.sh
VOLUME /data
CMD ["sh","-c","/hostyoself host --folder /data"]
ENTRYPOINT ["/entrypoint.sh"]

13
bin/docker-build.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
#
# Wrapper to build our contianer
#
# Errors are fatal
set -e
pushd $(dirname $0)/.. > /dev/null
docker build . -t hostyoself

23
bin/docker-run.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
#
# Wrapper to build our contianer
#
# Errors are fatal
set -e
pushd $(dirname $0)/.. > /dev/null
./bin/docker-build.sh
#
# We're setting the current directory to be /data for testing/development.
#
echo "# "
echo "# Mounting current directory as /data for testing..."
echo "# "
echo "# Serve with up $0 host --folder /data"
echo "# "
docker run -v $(pwd):/data hostyoself $@

15
bin/entrypoint.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
#
# Entrypoint for the Docker container
#
set -e
#
# Change into our data dire
#
exec /hostyoself $@