go-container: ENV в Dockerfile, без хардкода в Go
This commit is contained in:
@@ -12,5 +12,13 @@ RUN go mod init tf-registry && go mod tidy && CGO_ENABLED=0 go build -o registry
|
||||
FROM alpine:3.21
|
||||
RUN apk --no-cache add ca-certificates
|
||||
COPY --from=builder /app/registry /registry
|
||||
|
||||
# ── Non-secret defaults (change here → rebuild → push → redeploy) ─────────
|
||||
ENV S3_ENDPOINT=s3.msk-1.ngcloud.ru \
|
||||
S3_BUCKET=terraform-registry \
|
||||
S3_PREFIX=registry.kube5s.ru \
|
||||
PORT=5000
|
||||
# ── Secrets go in UI jsonEnv: S3_ACCESS_KEY, S3_SECRET_KEY ─────────────────
|
||||
|
||||
EXPOSE 5000
|
||||
CMD ["/registry"]
|
||||
|
||||
+3
-8
@@ -71,16 +71,11 @@ type GPGPublicKey struct {
|
||||
func main() {
|
||||
// 1. Init S3 Connection
|
||||
if hostname == "" {
|
||||
hostname = "localhost:8080"
|
||||
hostname = "localhost:5000"
|
||||
}
|
||||
// ── TEMPORARY HARDCODE ──────────────────────────────────────────────────
|
||||
// S3 data is stored under old hostname prefix from the previous Go deploy.
|
||||
// TODO: REMOVE after devops adds jsonEnv editing to containerk8s "modify".
|
||||
// Then read from ENV: s3Prefix = os.Getenv("S3_PREFIX")
|
||||
// And set in UI jsonEnv: "S3_PREFIX": "registry.kube5s.ru"
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// S3_PREFIX default comes from Dockerfile ENV; override in jsonEnv if needed.
|
||||
if s3Prefix == "" {
|
||||
s3Prefix = "registry.kube5s.ru"
|
||||
s3Prefix = hostname
|
||||
}
|
||||
|
||||
endpoint := os.Getenv("S3_ENDPOINT")
|
||||
|
||||
Reference in New Issue
Block a user