From c35851dc71e57e1640e8ae586a29105fa1495241 Mon Sep 17 00:00:00 2001 From: barthel Date: Thu, 23 Mar 2023 08:07:48 +0100 Subject: [PATCH 1/6] Replace ERD (Haskell) with erd-go #343 --- Dockerfile | 31 ++++++++----------------------- README.adoc | 2 ++ README.md | 6 ++++++ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5490cf8..67e1f8e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,30 +45,13 @@ RUN apk add --no-cache ruby \ "asciidoctor-pdf:${ASCIIDOCTOR_PDF_VERSION}" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Haskell build for: erd +# Install erd-go (https://github.com/kaishuu0123/erd-go) as replacement for erd (https://github.com/BurntSushi/erd) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Alpine 3.16 is the last known working version for building erd (dynamic linking) -FROM alpine:3.16 AS erd-builder +FROM golang:alpine as erd-builder +RUN apk add git \ + && go install github.com/kaishuu0123/erd-go@latest -## Always use the latest dependencies available for the current Alpine distribution -# hadolint ignore=DL3018 -RUN apk add --no-cache \ - alpine-sdk \ - cabal \ - ghc-dev \ - ghc \ - gmp-dev \ - gnupg \ - libffi-dev \ - linux-headers \ - perl-utils \ - wget \ - xz \ - zlib-dev \ - && cabal v2-update \ - && cabal v2-install erd - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ # Final image # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM main-minimal AS main @@ -139,7 +122,9 @@ RUN apk add --no-cache \ seqdiag \ && apk del -r --no-cache .pythonmakedepends -COPY --from=erd-builder /root/.cabal/bin/erd /bin/ +COPY --from=erd-builder /go/bin/erd-go /usr/local/bin/ +# for backward compatibility +RUN ln -snf /usr/local/bin/erd-go /usr/local/bin/erd WORKDIR /documents VOLUME /documents diff --git a/README.adoc b/README.adoc index 3af6f36c..f1cebd79 100644 --- a/README.adoc +++ b/README.adoc @@ -41,6 +41,8 @@ This image uses Alpine Linux {ALPINE_VERSION} as base image. NOTE: Docker Engine link:https://docs.docker.com/engine/release-notes/#20100[20.10] or later is required (or any container engine supporting link:https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0[Alpine 3.14]) to avoid unexpected `No such file or directory` errors (such as link:https://github.com/asciidoctor/docker-asciidoctor/issues/214[#214] or link:https://github.com/asciidoctor/docker-asciidoctor/issues/215[#215]). +NOTE: This image uses the Go-based https://github.com/kaishuu0123/erd-go/[erd-go] instead of the original Haskell-based https://github.com/BurntSushi/erd[erd] to allow the Docker image to be provided as a multi-platform image. + == How to use it Just run: diff --git a/README.md b/README.md index e323f481..96ac0a01 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ Docker Engine [20.10](https://docs.docker.com/engine/release-notes/#20100) or la +
+ +This image uses the Go-based [erd-go](https://github.com/kaishuu0123/erd-go/) instead of the original Haskell-based [erd](https://github.com/BurntSushi/erd) to allow the Docker image to be provided as a multi-platform image. + +
+ ## How to use it Just run: From ab7c0e436d835f039d9d086b93549e968862cf0f Mon Sep 17 00:00:00 2001 From: barthel Date: Fri, 24 Mar 2023 13:45:20 +0100 Subject: [PATCH 2/6] Uses version (tag) instead of latest. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 67e1f8e8..dc6140e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN apk add --no-cache ruby \ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM golang:alpine as erd-builder RUN apk add git \ - && go install github.com/kaishuu0123/erd-go@latest + && go install github.com/kaishuu0123/erd-go@v2.0.0 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ # Final image From d9e054c9ab927549528d6a2f9fecaa592c634c32 Mon Sep 17 00:00:00 2001 From: barthel Date: Fri, 24 Mar 2023 17:06:26 +0100 Subject: [PATCH 3/6] Fix version as suggested by dduportal Co-authored-by: Damien Duportal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dc6140e6..dafd7301 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN apk add --no-cache ruby \ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM golang:alpine as erd-builder RUN apk add git \ - && go install github.com/kaishuu0123/erd-go@v2.0.0 + && go install github.com/kaishuu0123/erd-go/v2@v2.0.0 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ # Final image From 3f71fae279a8e98dac98643c46970bfe2de0f130 Mon Sep 17 00:00:00 2001 From: barthel Date: Fri, 24 Mar 2023 17:07:44 +0100 Subject: [PATCH 4/6] Uses 'original' golang version as suggested by dduportal Co-authored-by: Damien Duportal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dafd7301..f3004b89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN apk add --no-cache ruby \ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Install erd-go (https://github.com/kaishuu0123/erd-go) as replacement for erd (https://github.com/BurntSushi/erd) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -FROM golang:alpine as erd-builder +FROM golang:1.12-alpine as erd-builder RUN apk add git \ && go install github.com/kaishuu0123/erd-go/v2@v2.0.0 From 3df55efc9716b8844d49c544ee0e85e60958456e Mon Sep 17 00:00:00 2001 From: barthel Date: Fri, 24 Mar 2023 17:08:47 +0100 Subject: [PATCH 5/6] Uses --no-cache as dduportal suggested Co-authored-by: Damien Duportal --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f3004b89..3c6ba3b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,7 @@ RUN apk add --no-cache ruby \ # Install erd-go (https://github.com/kaishuu0123/erd-go) as replacement for erd (https://github.com/BurntSushi/erd) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM golang:1.12-alpine as erd-builder -RUN apk add git \ +RUN apk add --no-cache git \ && go install github.com/kaishuu0123/erd-go/v2@v2.0.0 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ From 5e250170419c43c12c3f3162e167295effa13212 Mon Sep 17 00:00:00 2001 From: barthel Date: Sat, 25 Mar 2023 21:12:45 +0100 Subject: [PATCH 6/6] Uses go build instead of go install as dduportal suggested. --- Dockerfile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c6ba3b0..1f5a3fe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# Golang version defined in https://github.com/kaishuu0123/erd-go/blob/${ERD_VERSION}/go.mod#L3 +ARG ERD_GOLANG_VERSION=1.15 ARG alpine_version=3.17.2 FROM alpine:${alpine_version} AS base @@ -47,9 +49,17 @@ RUN apk add --no-cache ruby \ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Install erd-go (https://github.com/kaishuu0123/erd-go) as replacement for erd (https://github.com/BurntSushi/erd) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -FROM golang:1.12-alpine as erd-builder +FROM golang:${ERD_GOLANG_VERSION}-alpine as erd-builder +ARG ERD_VERSION=v2.0.0 +## Always use the latest git package +# go install or go get cannot be used the go.mod syntax of erd-go is not following the Golang semver properties, +# leading to errors whatever method is used. +# This fixes it by using a go build method to generate the binary instead. +# hadolint ignore=DL3018 RUN apk add --no-cache git \ - && go install github.com/kaishuu0123/erd-go/v2@v2.0.0 + && git clone https://github.com/kaishuu0123/erd-go -b "${ERD_VERSION}" /app +WORKDIR /app +RUN CGO_ENABLED=0 GOOS=linux go build # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ # Final image @@ -122,7 +132,7 @@ RUN apk add --no-cache \ seqdiag \ && apk del -r --no-cache .pythonmakedepends -COPY --from=erd-builder /go/bin/erd-go /usr/local/bin/ +COPY --from=erd-builder /app/erd-go /usr/local/bin/ # for backward compatibility RUN ln -snf /usr/local/bin/erd-go /usr/local/bin/erd