Resolves #6
---
Dockerfile | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 Dockerfile
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..48a6ddd
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,9 @@
+FROM golang:1.14-alpine AS builder
+WORKDIR /go/src/git.sr.ht/~ancarda/tls-redirector
+COPY *.go ./
+RUN CGO_ENABLED=0 GOOS=linux go build -a -o app .
Why is CGo disabled? AFAIK this package doesn't use CGo, so it
should not need to be disabled. Similarly with -a, perhaps that is
necessary in a container?
Also, can GOOS be omitted? I feel like letting Go determine the OS
automatically should work fine here, given we specify Alpine Linux.
+
+FROM alpine:latest
This may be my own Docker ignorance, but it seems like there's
basically two files here -- one build step, and one run step. Is it
conventional to have these be in the same file?
+COPY --from=builder /go/src/git.sr.ht/~ancarda/tls-redirector/app .
Is this the compiled binary? Does it make sense to be copied
somewhere like /usr/bin/tls-redirector instead?
+EXPOSE 80
+CMD ["./app"]
Any chance "app" could be changed? If we drop -o, it should default
to "tis-redirector", which I feel would make more sense if someone
were to run `ps' inside the container.
I don't know if people do that though. I imagine not very often.
Still, I like for things to be as understandable as possible.
Your hunch is right, there ain't much to see:
$ dk run --name tls-redirector tls-redirector &
[1] 9645
$ ❯ dk exec -it tls-redirector /bin/sh
/ # ps
PID USER TIME COMMAND
1 root 0:00 ./app
11 root 0:00 /bin/sh
16 root 0:00 ps
But —
--
2.27.0
Thank you so much for doing this!
I do have some questions about this patch. Some might be the result
of ignorance as I don't know much about Docker.