diff --git a/Dockerfile b/Dockerfile index c5490cf8..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 @@ -45,30 +47,21 @@ 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 - -## Always use the latest dependencies available for the current Alpine distribution +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 \ - 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 +RUN apk add --no-cache git \ + && git clone https://github.com/kaishuu0123/erd-go -b "${ERD_VERSION}" /app +WORKDIR /app +RUN CGO_ENABLED=0 GOOS=linux go build -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ # Final image # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # FROM main-minimal AS main @@ -139,7 +132,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 /app/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 +