Merge remote-tracking branch 'upstream/master' into scenarios-a407
This commit is contained in:
commit
af97795e42
8 changed files with 44 additions and 8 deletions
|
|
@ -3,19 +3,35 @@ FROM debian:latest
|
|||
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ca-certificates
|
||||
RUN apt-get update && apt-get install -y ca-certificates curl dumb-init sudo
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash -s - && \
|
||||
apt-get install -y nodejs
|
||||
RUN npx playwright install-deps
|
||||
|
||||
RUN adduser --gecos '' --disabled-password debian \
|
||||
&& echo "debian ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
|
||||
|
||||
RUN curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5/fixuid-0.5-linux-$TARGETARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
|
||||
&& chown root:root /usr/local/bin/fixuid \
|
||||
&& chmod 4755 /usr/local/bin/fixuid \
|
||||
&& mkdir -p /etc/fixuid \
|
||||
&& printf "user: debian\ngroup: debian\npaths: [/home/debian]\n" > /etc/fixuid/config.yml
|
||||
|
||||
COPY ./d2-*-linux-$TARGETARCH.tar.gz /tmp
|
||||
ADD ./Dockerfile_entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN mkdir -p /usr/local/lib/d2 \
|
||||
&& tar -C /usr/local/lib/d2 -xzf /tmp/d2-*-linux-"$TARGETARCH".tar.gz \
|
||||
&& /usr/local/lib/d2/d2-*/scripts/install.sh \
|
||||
&& rm -Rf /tmp/d2-*-linux-"$TARGETARCH".tar.gz
|
||||
|
||||
WORKDIR /root/src
|
||||
USER debian:debian
|
||||
RUN d2 init-playwright
|
||||
|
||||
WORKDIR /home/debian/src
|
||||
EXPOSE 8080
|
||||
ENV PORT 8080
|
||||
ENV HOST 0.0.0.0
|
||||
ENV BROWSER false
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/d2"]
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
|
|
|
|||
6
ci/release/Dockerfile_entrypoint.sh
Executable file
6
ci/release/Dockerfile_entrypoint.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
eval "$(fixuid -q)"
|
||||
|
||||
exec dumb-init /usr/local/bin/d2 "$@"
|
||||
|
|
@ -253,6 +253,7 @@ build_docker_image() {
|
|||
if [ -n "${PUSH_DOCKER-}" -o -n "${RELEASE-}" ]; then
|
||||
flags='--push --platform linux/amd64,linux/arm64'
|
||||
fi
|
||||
sh_c rsync --archive --human-readable ./ci/release/Dockerfile_entrypoint.sh "./ci/release/build/$VERSION"
|
||||
sh_c docker buildx build $flags -t "$D2_DOCKER_IMAGE:$VERSION" -t "$D2_DOCKER_IMAGE:latest" --build-arg "VERSION=$VERSION" -f ./ci/release/Dockerfile "./ci/release/build/$VERSION"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#### Features 🚀
|
||||
|
||||
- The [Dockerfile](./docs/INSTALL.md#docker) now supports rendering PNGs [#594](https://github.com/terrastruct/d2/issues/594)
|
||||
- There was a minor breaking change as part of this where the default working directory of the Dockerfile is now `/home/debian/src` instead of `/root/src` to allow UID remapping with [`fixuid`](https://github.com/boxboat/fixuid).
|
||||
|
||||
#### Improvements 🧹
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ Example usage:
|
|||
|
||||
```sh
|
||||
echo 'x -> y' >helloworld.d2
|
||||
docker run --rm -it -u "$(id -u):$(id -g)" -v "$PWD:/root/src" \
|
||||
docker run --rm -it -u "$(id -u):$(id -g)" -v "$PWD:/home/debian/src" \
|
||||
-p 127.0.0.1:8080:8080 terrastruct/d2:v0.1.2 --watch helloworld.d2
|
||||
# Visit http://127.0.0.1:8080
|
||||
```
|
||||
|
|
|
|||
2
go.mod
generated
2
go.mod
generated
|
|
@ -21,7 +21,7 @@ require (
|
|||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
|
||||
gonum.org/v1/plot v0.12.0
|
||||
nhooyr.io/websocket v1.8.7
|
||||
oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1
|
||||
oss.terrastruct.com/util-go v0.0.0-20230124223326-041fa96d3331
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
|
|||
4
go.sum
generated
4
go.sum
generated
|
|
@ -266,6 +266,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
|
||||
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1 h1:mhZsCUUqGInjqOsxF0TlP1TVwpBC+O2CUgKs9Xw2ViU=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230123214952-834a0f3992d1/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230124223326-041fa96d3331 h1:5B6+mum6eq9bOtAkHK15T6rvPgtijxu/v165uEAqd7I=
|
||||
oss.terrastruct.com/util-go v0.0.0-20230124223326-041fa96d3331/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU=
|
||||
rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=
|
||||
|
|
|
|||
10
main.go
10
main.go
|
|
@ -96,6 +96,8 @@ func run(ctx context.Context, ms *xmain.State) (err error) {
|
|||
|
||||
if len(ms.Opts.Flags.Args()) > 0 {
|
||||
switch ms.Opts.Flags.Arg(0) {
|
||||
case "init-playwright":
|
||||
return initPlaywright()
|
||||
case "layout":
|
||||
return layoutCmd(ctx, ms, ps)
|
||||
case "fmt":
|
||||
|
|
@ -322,3 +324,11 @@ func populateLayoutOpts(ctx context.Context, ms *xmain.State, ps []d2plugin.Plug
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initPlaywright() error {
|
||||
pw, err := png.InitPlaywright()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return pw.Cleanup()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue