Add support to run it in docker

This commit is contained in:
Marcel Hintermann
2024-06-05 14:48:04 +02:00
parent f0bb55c39b
commit bc6a82631d
2 changed files with 47 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
FROM golang:1.22-alpine3.19 AS builder
# go mod cache layer
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 go build -o /out/pastepass main.go
FROM alpine:3.19
ENV USER=pastepass
ENV UID=1000
ENV GID=1000
ENV APP_DIR=/app
ENV DATA_DIR=/data
RUN apk add --no-cache tini ca-certificates \
&& addgroup -g $GID -S $USER \
&& adduser -u $UID -S -G $USER $USER
WORKDIR $APP_DIR
COPY --from=builder /out/pastepass .
RUN mkdir -p $DATA_DIR && chown $UID:$GID $DATA_DIR
USER $USER
EXPOSE 8008
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./pastepass", "-db-path", "/data/pastepass.db"]
+14
View File
@@ -52,6 +52,20 @@ Use the `-h` option to find all options:
./pastepass -h
```
#### Run with docker
Build the image
```bash
git clone https://github.com/v1k45/pastepass.git && cd pastepass
docker build -t pastepass .
```
Run the image on the port 10001 with a volume mounted in `path/on/host` to store the database. ()
```bash
docker run -p 10001:8008 -v /path/on/host:/data pastepass
```
#### Options
| Option | Description | Default |