diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8d0c3ee --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index 7fc0bdb..3416341 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/mailrelay.json b/mailrelay.json index b2e82a0..e4fc9e7 100644 --- a/mailrelay.json +++ b/mailrelay.json @@ -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": ["*"] } diff --git a/client.go b/src/client.go similarity index 100% rename from client.go rename to src/client.go diff --git a/go.mod b/src/go.mod similarity index 100% rename from go.mod rename to src/go.mod diff --git a/go.sum b/src/go.sum similarity index 100% rename from go.sum rename to src/go.sum diff --git a/main.go b/src/main.go similarity index 100% rename from main.go rename to src/main.go diff --git a/server.go b/src/server.go similarity index 100% rename from server.go rename to src/server.go