go-sqlcmd icon indicating copy to clipboard operation
go-sqlcmd copied to clipboard

Provide Docker image via registry

Open dedo1911 opened this issue 9 months ago • 3 comments

As of #153 the docker image is being provided via Github Release Page, which is not optimal

Previous mssql-tools are correctly released: https://hub.docker.com/r/microsoft/mssql-tools

New go-sqlcmd docker image is expected to be correctly tagged on a registry, being it Dockerhub or Microsoft's own MCR https://mcr.microsoft.com

Current workaround provided by third-party: https://github.com/fabiang/docker-sqlcmd

dedo1911 avatar Apr 15 '25 10:04 dedo1911

Using a third party is an unacceptable solution in contexts where container security is taken into account. Please provide official images for official tools.

CappyT avatar Apr 15 '25 10:04 CappyT

For now, we’ve opted to build and host our own non-root image in our private registry.

Since version v1.7.0 (released in June 2024), Docker images are no longer published in the GitHub releases. As a result, the latest available official container image is now over a year old.

This was previously addressed in #153, but it seems the release process has since been reverted, and no recent builds are available.

Here’s the Dockerfile we’re using to build a minimal, non-root container based on the latest tag:

FROM golang:1 AS builder
RUN git clone https://github.com/microsoft/go-sqlcmd.git && \
    cd go-sqlcmd && \
    git checkout $(git tag --sort=version:refname | tail -n 1) && \
    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
        -o /sqlcmd \
        -ldflags="-X main.version=$(git tag --sort=version:refname | tail -n 1)" \
        ./cmd/modern

FROM gcr.io/distroless/static:nonroot
COPY --from=builder /sqlcmd /sqlcmd
USER 1002
ENTRYPOINT ["/sqlcmd"]

We hope this helps others with similar needs until official container builds are available again.

CC: @shueybubbles @stuartpa — tagging in case this context is useful or if there’s interest in restoring the Docker image publishing process.

dedo1911 avatar Jul 09 '25 10:07 dedo1911

Meanwhile, my solution with non-root image and without binary rebuilding https://github.com/bonddim/go-sqlcmd

bonddim avatar Oct 21 '25 20:10 bonddim