aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md51
-rw-r--r--docker/Dockerfile6
2 files changed, 33 insertions, 24 deletions
diff --git a/README.md b/README.md
index fee26c7..a3e6e4a 100644
--- a/README.md
+++ b/README.md
@@ -3,29 +3,38 @@
A thing that tells `go get` where to get Go packages and redirects users
to https://godoc.org.
-You need to set up the following environment variables for it to work:
+## systemd Configuration
-* `DEST` for the base URL that will be used to build the repository URL,
-* `PREFIX` for the prefix that must be removed from your package name,
- e.g. `golang.org/x/` for `golang.org/x/image`, and
-* `VCS` for the type of VCS you are using, e.g. `git`.
+`go-import-redirect` takes the following flags:
-There are three modes of operation:
+* `-addr` for the address on which `go-import-redirect` should listen.
+ It can either be a normal `IP:PORT` address or an absolute path to a
+ UNIX socket that will be created. Defaults to `localhost:8080`. See
+ https://golang.org/pkg/net/#Dial for more details.
+* `-from` for the prefix that must be removed from your package name,
+ e.g. `golang.org/x/` for `golang.org/x/image`.
+* `-to` for the URL that will be used to build the repository URL.
+* `-vcs` for the type of VCS you are using, e.g. `git`. Defaults to
+ `git`.
-1. **As a systemd service.** In this mode, it is recommended to enable
- the companion systemd socket and configure that. systemd will only
- start the service when needed. If you are not using the companion
- systemd socket but rather the systemd service directly, you will need
- to set the `ADDR` environment variable to tell go-import-redirect how
- to listen for incoming connections. If `ADDR` is set and starts with
- `/`, go-import-redirect will treat it as a UNIX socket path. If
- `ADDR` is not set, it will default to `:8080`. See
- https://golang.org/pkg/net/#Dial for more details.
+It is recommended to enable the companion systemd socket and customize
+it so systemd can start the service when needed and pass the socket to
+`go-import-redirect`.
-2. **Inside a Docker container.** In this mode, the port 8080 will be
- exposed and no other environment variable besides the ones above need
- to be set.
+Likewise, you must customize the service definition to pass the right
+flag values.
-3. **As an AWS Lambda.** This is very similar to Docker. You will need
- to set the environment variables above. Note that this version needs
- to be compiled as a Linux binary and with the `aws` build tag set.
+## AWS Lambda Configuration
+
+The AWS Lambda version requires the use of the following environment
+variables: `FROM`, `TO`, and `VCS`. Those have the same semantics as the
+flags described above.
+
+Note that this version needs to be compiled as a Linux binary and with
+the `aws` build tag set.
+
+## Docker Configuration
+
+You can build the Docker image as usual, and pass the `-from`, `-to`,
+and `-vcs` flags when you invoke `docker run`. The `-addr` flag is
+already set to an appropriate value in the Dockerfile.
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 13dd13f..cd1fe2a 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,11 +1,11 @@
-FROM golang:1.15
+FROM golang:1.17
WORKDIR /root
COPY . ./
ENV CGO_ENABLED=0
-RUN go build
+RUN go build -tags nosystemd
FROM scratch
COPY --from=0 /root/go-import-redirect /go-import-redirect
EXPOSE 8080
-ENTRYPOINT ["/go-import-redirect"]
+ENTRYPOINT ["/go-import-redirect", "-addr", ":8080"]