dockerizing

This commit is contained in:
Philippe Beaulieu 2020-04-09 09:34:39 -04:00
parent fd213dd450
commit b23950eed9
8 changed files with 41 additions and 2 deletions

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
# Dockerfile References: https://docs.docker.com/engine/reference/builder/
# Start from the latest golang base image
FROM golang:latest as builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY src/* ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
######## Start a new stage from scratch #######
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/main .
# Command to run the executable
CMD ["./main"]

View File

@ -77,6 +77,15 @@ sudo systemctl enable mailrelay
Now `mailrelay` runs as a service daemon and will automatically start after reboot.
## Example 3 (Docker)
edit mailrelay.json as needed then build container and run it
```
docker build -t mailrelay .
docker run -v $PWD/mailrelay.json:/etc/mailrelay.json mailrelay
```
## Feedback
Send any questions or comments to wiggin77@warpmail.net

View File

@ -3,7 +3,7 @@
"smtp_port": 465,
"smtp_username": "username@fastmail.com",
"smtp_password": "secret_app_password",
"local_listen_port": 2525,
"local_listen_ip": "0.0.0.0"
"local_listen_port": 25,
"local_listen_ip": "0.0.0.0",
"allowed_hosts": ["*"]
}

View File

View File