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

EY-4245: Skriv proxyen over til å basere seg på distroless-baseimage #305

Merged
merged 5 commits into from
Aug 5, 2024
Merged
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
11 changes: 7 additions & 4 deletions apps/etterlatte-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM ghcr.io/navikt/baseimages/temurin:21

COPY import-vault-token.sh /init-scripts
FROM gcr.io/distroless/java21
ENV TZ="Europe/Oslo"
ENV JDK_JAVA_OPTIONS="-Dhttp.proxyHost=webproxy.nais -Dhttps.proxyHost=webproxy.nais -Dhttp.proxyPort=8088 -Dhttps.proxyPort=8088 -Dhttp.nonProxyHosts=localhost|127.0.0.1|10.254.0.1|*.local|*.adeo.no|*.nav.no|*.aetat.no|*.devillo.no|*.oera.no|*.nais.io|*.aivencloud.com|*.intern.dev.nav.no"
WORKDIR /app
COPY build/libs/*.jar ./

EXPOSE 8080
USER nonroot
CMD ["app.jar"]
11 changes: 0 additions & 11 deletions apps/etterlatte-proxy/import-vault-token.sh

This file was deleted.

20 changes: 17 additions & 3 deletions apps/etterlatte-proxy/src/main/kotlin/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.server.config.ApplicationConfig
import no.nav.etterlatte.routes.httpClientWithProxy
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.io.path.exists

data class Config(
val sts: Sts,
Expand Down Expand Up @@ -44,13 +47,24 @@ suspend fun ApplicationConfig.load() =
soapUrl = property("sts.soapUrl").getString(),
serviceuser =
Config.Sts.ServiceUser(
name = property("serviceuser.name").getString(),
password = property("serviceuser.password").getString()
name = name(),
password = password()
)
),
aad =
Config.AAD(
metadata = httpClientWithProxy().use { it.get(property("aad.wellKnownUrl").getString()).body() },
clientId = property("aad.clientId").getString()
)
)
)

private fun name() =
Paths.get("/secrets/srvetterlatte/username")
.takeIf { it.exists() }
?.let { Files.readString(it) }
?: "srvetterlatte"

private fun password() = Paths.get("/secrets/srvetterlatte/password")
.takeIf { it.exists() }
?.let { Files.readString(it) }
?: "srv-password"
7 changes: 0 additions & 7 deletions apps/etterlatte-proxy/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ simuleringOppdrag {
url = ${?SIMULERING_OPPDRAG_URL}
}

serviceuser {
name = "srvetterlatte"
password = "srv-password"
name = ${?SERVICEUSER_USERNAME}
password = ${?SERVICEUSER_PASSWORD}
}

aad {
wellKnownUrl = "https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b/v2.0/.well-known/openid-configuration"
wellKnownUrl = ${?AZURE_APP_WELL_KNOWN_URL}
Expand Down