From 2975001e08a657c02710c4161e71cef4d4cfb4c3 Mon Sep 17 00:00:00 2001 From: Rob Styles Date: Tue, 1 Oct 2024 14:50:39 +0100 Subject: [PATCH] Add dockerfile; fix go build error; --- Dockerfile | 26 ++++++++++++++++++++++++++ handler/endpoints.go | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cdcfb35 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ + +FROM ubuntu:20.04 AS sessionmanagerplugin +# session manager is not available in alpine, so we grab it from Ubuntu +ADD https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_arm64/session-manager-plugin.deb . +RUN dpkg -i "session-manager-plugin.deb" + +FROM golang:alpine AS homebrew-dbc + + +COPY --from=sessionmanagerplugin /usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/ +RUN apk update +RUN apk add aws-cli +RUN apk add socat + +WORKDIR /homebrew-dbc +COPY . . + +# This 👇🏼 should be done in the repo probably. +RUN go get -u github.com/aws/aws-sdk-go-v2/... +RUN go build + +EXPOSE 5432 +# socat routes requests to port 5432 to port 5555 where the ssm tunnel is running. +# this is needed because the ssm tunnel only accepts connections from inside the same container. +CMD [ "sh", "-c", "socat tcp-listen:5432,reuseaddr,fork tcp:localhost:5555 & ./dbc connect --host=${HOST} --localport=5555" ] + diff --git a/handler/endpoints.go b/handler/endpoints.go index 91d5839..2ffc47d 100644 --- a/handler/endpoints.go +++ b/handler/endpoints.go @@ -61,7 +61,7 @@ func getEndpoints() { DBId: *i.DBInstanceIdentifier, Type: "Instance", Endpoints: []string{*i.Endpoint.Address}, - IAM: *&i.IAMDatabaseAuthenticationEnabled, + IAM: *i.IAMDatabaseAuthenticationEnabled, }) } }