From 88941ef36d4bd24246e397705b9103abe2544f7f Mon Sep 17 00:00:00 2001 From: Pierre Prinetti Date: Fri, 6 Sep 2024 15:58:09 +0200 Subject: [PATCH] Add a Containerfile --- Containerfile | 23 +++++++++++++++++++++++ README.md | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..f40206b --- /dev/null +++ b/Containerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 + +FROM docker.io/library/golang:1.22 AS build + +WORKDIR /src + +COPY go.mod go.sum ./ +RUN go mod download + +COPY ./pkg ./pkg +COPY ./cmd ./cmd + +RUN CGO_ENABLED=0 GOOS=linux go build -o /openstack-proxy ./cmd/openstack-proxy + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ENV OS_CLOUD=openstack OS_CLIENT_CONFIG_FILE=/config/clouds.yaml + +EXPOSE 13000 + +COPY --from=build /openstack-proxy / + +ENTRYPOINT ["/openstack-proxy"] diff --git a/README.md b/README.md index 6eae3ea..94dbdd8 100644 --- a/README.md +++ b/README.md @@ -22,21 +22,54 @@ By default the server will listen on localhost on port 13000. ### Local server -```shell +```bash export OS_CLOUD=openstack ./openstack-proxy -o proxied-clouds.yaml ``` -```shell +```bash export OS_CLIENT_CONFIG_FILE=./proxied-clouds.yaml openstack server list ``` ### On the network, with HTTPS -```shell +```bash ./openstack-proxy \ --url https://myserver.example.com:13000 \ --cert /var/run/osp-cert.pem \ --key /var/run/osp-key.pem' \ -o proxied-clouds.yaml ``` + +## Containerized + +An image of `openstack-proxy` is available on `quay.io/pierreprinetti/openstack-proxy`. + +Here is an example of how to use it. This example uses the clouds.yaml in the +default location, edit as necessary: + +```bash +export OS_CLOUD=openstack # Name of the target cloud in clouds.yaml +export OS_CLIENT_CONFIG_FILE="$(mktemp -d)/clouds.yaml" # Where to write the generated clouds.yaml +podman run \ + --name openstack-proxy \ + -d \ + --rm \ + -v ${XDG_CONFIG_HOME:-${HOME}/.config}/openstack/clouds.yaml:/config/clouds.yaml:Z,ro \ + -v $(dirname "$OS_CLIENT_CONFIG_FILE"):/out:z \ + --env OS_CLOUD=$OS_CLOUD \ + -p 13000:13000 \ + quay.io/pierreprinetti/openstack-proxy -o "/out/$(basename "$OS_CLIENT_CONFIG_FILE")" +``` + +Logs can be inspected in a separate terminal: + +```bash +podman container logs --follow openstack-proxy +``` + +To terminate the container: + +```bash +podman container stop openstack-proxy +```