Skip to content

Chore updates #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ FROM --platform=${BUILDPLATFORM} alpine:3 AS tools
ARG SQLCMD_VERSION=v1.8.0
ARG TARGETARCH
RUN apk add --update-cache --no-cache curl jq xz && \
curl -sSL $(curl -sSL "https://api.github.com/repos/microsoft/go-sqlcmd/releases/tags/${SQLCMD_VERSION}" | \
jq -r --arg arch "${TARGETARCH}" '.assets[] | select(.name | test(".*linux.*" + $arch + ".*")).browser_download_url') \
curl -sSL https://github.com/microsoft/go-sqlcmd/releases/download/${SQLCMD_VERSION}/sqlcmd-linux-${TARGETARCH}.tar.bz2 \
| tar -xj

FROM gcr.io/distroless/static:nonroot@sha256:d71f4b239be2d412017b798a0a401c44c3049a3ca454838473a4c32ed076bfea
COPY --from=tools /sqlcmd /sqlcmd
USER nonroot:nonroot
USER 65532:65532
ENTRYPOINT ["/sqlcmd"]
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

[docker-hub]: https://hub.docker.com/r/bonddim/go-sqlcmd
[![Docker](https://github.com/bonddim/go-sqlcmd/actions/workflows/docker.yaml/badge.svg)](https://github.com/bonddim/go-sqlcmd/actions/workflows/docker.yaml)
[![Docker Image Version](https://img.shields.io/docker/v/bonddim/go-sqlcmd)][docker-hub]
[![Docker Image Size](https://img.shields.io/docker/image-size/bonddim/go-sqlcmd)][docker-hub]
[![Docker Pulls](https://img.shields.io/docker/pulls/bonddim/go-sqlcmd)][docker-hub]
[![Docker Image Version](https://img.shields.io/docker/v/bonddim/go-sqlcmd?logo=docker&label=latest)][docker-hub]
[![Docker Image Size](https://img.shields.io/docker/image-size/bonddim/go-sqlcmd?logo=docker)][docker-hub]
[![Docker Pulls](https://img.shields.io/docker/pulls/bonddim/go-sqlcmd?logo=docker&label=pulls)][docker-hub]
[![GitHub License](https://img.shields.io/github/license/bonddim/go-sqlcmd)](https://github.com/bonddim/go-sqlcmd?tab=MIT-1-ov-file)

## About

- Uses [gcr.io/distroless/static:nonroot](https://github.com/GoogleContainerTools/distroless) as image base
- Supported architectures: **amd64**, **arm64**, **s390x**
- Uses [gcr.io/distroless/static:nonroot](https://github.com/GoogleContainerTools/distroless) as image base
- Uses [released sqlcmd](https://github.com/microsoft/go-sqlcmd/releases) binary
- Automated release process
- Updated automatically by Renovate

## Usage

Expand All @@ -23,6 +23,47 @@ docker pull bonddim/go-sqlcmd
docker pull ghcr.io/bonddim/go-sqlcmd
```

Docker container with mounted scripts to run:

```bash
docker run \
--rm \
-v $(pwd)/sql_scripts:/mnt/sql \
-e SQLCMDPASSWORD={{ password }} \
ghcr.io/bonddim/go-sqlcmd \
-i /mnt/sql \
-S {{ server }} \
-d {{ database }} \
-u {{ user }}
```

K8s pod with Entra ID authentication:

```yaml
apiVersion: v1
kind: Pod
metadata:
name: go-sqlcmd
labels:
azure.workload.identity/use: "true"
spec:
serviceAccountName: go-sqlcmd
containers:
- name: go-sqlcmd
image: bonddim/go-sqlcmd
args:
- --use-aad
- --server
- {{ server }}.database.windows.net
- --database-name
- {{ database }}
- --query
- {{ query }}
securityContext:
runAsNonRoot: true
...
```

Refer to official [docs](https://docs.microsoft.com/sql/tools/go-sqlcmd-utility) for syntax and command line arguments

## License
Expand Down