Skip to content

Commit

Permalink
Merge pull request #372 from k-wall/issue-371
Browse files Browse the repository at this point in the history
feat: add ASCIIToSVG (a2s binary) to container image.
  • Loading branch information
dduportal authored Aug 3, 2023
2 parents d98b43f + 9f614be commit 75a7117
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Golang version defined in https://github.com/kaishuu0123/erd-go/blob/${ERD_VERSION}/go.mod#L3
ARG ERD_GOLANG_VERSION=1.15
ARG ERD_GOLANG_BUILDER_TAG=1.15-alpine
ARG A2S_GOLANG_BUILDER_TAG=1.20-alpine3.18
ARG alpine_version=3.18.2
FROM alpine:${alpine_version} AS base

Expand Down Expand Up @@ -27,7 +28,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:${ERD_GOLANG_VERSION}-alpine as erd-builder
FROM golang:${ERD_GOLANG_BUILDER_TAG} 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,
Expand All @@ -39,6 +40,14 @@ RUN apk add --no-cache git \
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Install ASCIIToSVG https://github.com/asciitosvg/asciitosvg
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
FROM golang:${A2S_GOLANG_BUILDER_TAG} as a2s-builder
# Expects a git reference as there are no tags in the A2S repository
ARG A2S_VERSION=ca82a5c
RUN GOBIN=/app go install github.com/asciitosvg/asciitosvg/cmd/a2s@"${A2S_VERSION}"

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \
# Final image
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down Expand Up @@ -137,6 +146,7 @@ RUN apk add --no-cache --virtual .pythonmakedepends \
seqdiag \
&& apk del -r --no-cache .pythonmakedepends

COPY --from=a2s-builder /app/a2s /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
Expand Down
4 changes: 4 additions & 0 deletions tests/asciidoctor.bats
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ teardown() {
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" kramdoc --version
}

@test "a2s is installed and in the path" {
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" which a2s
}

@test "git command line tool is installed and in the path" {
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" which git
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" git --version
Expand Down
15 changes: 15 additions & 0 deletions tests/fixtures/sample-with-diagram.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ digraph g {
}
----

== ASCIIToSVG
[a2s, format="svg"]
....
.-------------------------.
| |
| .---.-. .-----. .-----. |
| | .-. | +--> | | <--| |
| | '-' | | <--| +--> | |
| '---'-' '-----' '-----' |
| ascii 2 svg |
| |
'-------------------------'
....


== Plantuml from external file...
[plantuml,activity,svg,align="center"]
----
Expand Down

0 comments on commit 75a7117

Please sign in to comment.