Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerizing #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
4 changes: 2 additions & 2 deletions mailrelay.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"smtp_port": 465,
"smtp_username": "[email protected]",
"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": ["*"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.