mirror of
https://github.com/schollz/hostyoself.git
synced 2026-01-23 02:15:14 +00:00
- 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:
parent
ab215af53e
commit
d34477f5f6
4 changed files with 59 additions and 2 deletions
10
Dockerfile
10
Dockerfile
|
|
@ -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
13
bin/docker-build.sh
Executable 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
23
bin/docker-run.sh
Executable 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
15
bin/entrypoint.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Entrypoint for the Docker container
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
#
|
||||
# Change into our data dire
|
||||
#
|
||||
exec /hostyoself $@
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue