~gsthnz/public-inbox

Add Docker build support v1 APPLIED

: 1
 Add Docker build support

 2 files changed, 51 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~gsthnz/public-inbox/patches/16024/mbox | git am -3
Learn more about email & git

[PATCH] Add Docker build support Export this patch

From: Timur Demin <me@tdem.in>

This adds a Dockerfile and a short instruction on how to use it to run
Satellite. Since the Makefile requires scdoc to be installed (which is
not present in golang:1.15), the Dockerfile runs go build manually
instead.
---
 Dockerfile | 24 ++++++++++++++++++++++++
 README.md  | 27 +++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 Dockerfile

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d781551
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,24 @@
FROM golang:1.15 AS builder

WORKDIR /app
COPY . /app

ENV CGO_ENABLED=0
RUN \
   go mod download -x && \
   go build -v -o /tmp/satellite .

FROM alpine:3.12 AS worker

WORKDIR /app
VOLUME /config
VOLUME /data

RUN adduser -D -u 1000 satellite && \
    mkdir -p /config && chown satellite /config && chmod 700 /config && \
    mkdir -p /data && chown satellite /data && chmod 700 /data

COPY --from=builder /tmp/satellite /app/satellite

USER satellite
CMD ["/app/satellite", "-c", "/config/config.toml"]
diff --git a/README.md b/README.md
index 4e513b2..c0d0bee 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,33 @@ This will install a sample configuration on
`/usr/local/share/satellite/satellite.toml` that you can later copy to
`/etc/satellite.toml`.

## Running with Docker

Build an image:

```
$ docker build -t satellite .
```

Create two directories to store certs/configuration and data served by
satellite (Satellite runs under UID 1000, so we need to grant it RWX on the
config dir), then run the container:

```
$ mkdir config
$ mkdir data
$ cat >config/satellite.toml <<EOF
[tls]
directory = "/config"
[[domain]]
name = "example.org"
root = "/data"
EOF
$ chown 1000 config
$ chmod 700 config
$ docker run -d -p 1965:1965 -v $(pwd)/config:/config -v $(pwd)/data:/data satellite
```

## Contributing
Patches and questions? Send to my [public
inbox](https://lists.sr.ht/~gsthnz/public-inbox):
-- 
2.29.2
Sent this as a new patch due to master branch heavily diverging with what my 
local copy turned into by 3 commits (not sure of the cause).

Notably a little overdue. :)

-- 
Regards,
Timur Demin
Hi there,

Thanks for the patch!

Sorry about the branch divergence, had to do a rebase because I fucked
up some commits.

To git.sr.ht:~gsthnz/satellite
   35ff8ae..36439f7  master -> master
--
Gustavo Heinz