~migadu/alps-devel

Add Dockerfile v1 REJECTED

Antoine Beaupré: 1
 optimize and simplify Dockerfile
sentriz: 1
 Add Dockerfile

 2 files changed, 22 insertions(+), 7 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/~migadu/alps-devel/patches/14442/mbox | git am -3
Learn more about email & git

[PATCH] Add Dockerfile Export this patch

example docker-compose:

```yml
alps:
  build: alps
  expose:
  - 80
  restart: unless-stopped
  command:
    - -theme
    - alps
    - imaps://imap.fastmail.com:993
    - smtps://smtp.fastmail.com:465
```
---
 Dockerfile | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Dockerfile

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..472a254
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,16 @@
FROM golang:1.14-alpine AS builder
RUN apk --no-cache add ca-certificates
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o alps -tags netgo -v -a -ldflags '-extldflags "-static"' cmd/alps/main.go

FROM scratch
COPY --from=builder /etc/ssl/certs/* /etc/ssl/certs/
COPY --from=builder /src/alps /
COPY --from=builder /src/themes /themes
COPY --from=builder /src/plugins /plugins
EXPOSE 80
ENTRYPOINT ["/alps", "-addr", ":80"]
-- 
2.26.2
Thanks for the patch! However I don't think we're interested in
maintaining a Dockerfile upstream.

[PATCH] optimize and simplify Dockerfile Export this patch

We keep the good stuff from the original implementation:

 * statically compiled
 * "FROM scratch"
 * sets up a `ca-certificates` base
 * ENTRYPOINT instead of CMD (so we don't have to do `docker run alps
   alps -h`)

... but also add the following:

 * go mod verify
 * single-step COPY
 * use the default golang image (Debian)
 * use the latest golang image (1.18)
 * use a non-privileged port (the default 1323) so this can run rootless

I also use a slightly different docker-compose.yml file.

---
version: "3.5"
services:
  alps:
    image: registry.gitlab.com/anarcat/alps
    container_name: alps
    restart: unless-stopped
    command:
    - -theme
    - alps
    - anarc.at
    ports:
    - "127.0.0.1:1323:1323"
    user: "65534"

I'll try to maintain a container image out of this in the
aforementioned GitLab registry. I'd happily to this here on sr.ht
either, but I am not aware of such a thing existing here (yet?).

Containers are a perfect match for alps: it's stateless, can be
compiled statically, so it makes for a really neat little container.

---
 Dockerfile | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 472a254..2fb7d14 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,8 @@
FROM golang:1.14-alpine AS builder
RUN apk --no-cache add ca-certificates
FROM golang:1.18 AS builder
RUN apt update && apt install -y ca-certificates
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 go build -o alps -tags netgo -v -a -ldflags '-extldflags "-static"' cmd/alps/main.go

@@ -12,5 +11,5 @@ COPY --from=builder /etc/ssl/certs/* /etc/ssl/certs/
COPY --from=builder /src/alps /
COPY --from=builder /src/themes /themes
COPY --from=builder /src/plugins /plugins
EXPOSE 80
ENTRYPOINT ["/alps", "-addr", ":80"]
EXPOSE 1323
ENTRYPOINT ["/alps"]
-- 
2.30.2