Skip to content

Commit

Permalink
Update project for GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
rglidden committed Aug 16, 2024
1 parent c076002 commit 89e5ab9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 85 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Publish Container

on:
workflow_dispatch:
push:
branches: ["main"]

permissions:
actions: read
contents: read
packages: write
security-events: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine Version
id: version
shell: bash
run: echo "sqlcmd=$(gh release view -R microsoft/go-sqlcmd --json tagName -q '.tagName')" >> $GITHUB_OUTPUT

- name: Download sqlcmd ${{ steps.version.outputs.sqlcmd }}
shell: bash
run: |
gh release download ${{ steps.version.outputs.sqlcmd }} --pattern sqlcmd-linux-amd64.tar.bz2 -R microsoft/go-sqlcmd
tar -xjvf sqlcmd-linux-amd64.tar.bz2
- name: "Build and Publish brocksolutions/sqlcmd:${{ steps.version.outputs.sqlcmd }}"
uses: brocksolutions/action-build-container@v3
with:
dockerfile-path: Dockerfile
image-name: sqlcmd
version: ${{ steps.version.outputs.sqlcmd }}
tag-latest: true
push-to-registry: true
47 changes: 25 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
ARG DEBIAN_VERSION=11
FROM debian:$DEBIAN_VERSION-slim
#------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
#------------------------------------------------------------------------------

RUN apt-get -qqq update \
&& apt-get install -y curl apt-transport-https locales gnupg2 \
&& locale-gen "en_US.UTF-8" \
\
&& export `grep "VERSION_ID" /etc/os-release | sed -e 's/^VERSION_ID=\"/VERSION_ID=/' -e 's/\"$//'` \
&& mkdir -p /etc/apt/keyrings/ \
&& curl --fail https://packages.microsoft.com/config/debian/$VERSION_ID/prod.list | \
sed -E 's#deb\s+\[#deb [signed-by=/etc/apt/keyrings/microsoft.gpg #; t; q1' | \
tee /etc/apt/sources.list.d/microsoft.list \
&& curl --fail https://packages.microsoft.com/keys/microsoft.asc | \
gpg --verbose --yes --no-tty --batch --dearmor -o /etc/apt/keyrings/microsoft.gpg \
\
&& apt-get -qqq update \
&& apt-get install -y sqlcmd \
&& apt-get remove -y curl apt-transport-https gnupg2 \
&& rm -f /etc/apt/sources.list.d/msprod.list \
&& rm -rf /var/lib/apt/lists/*
# Example:
# docker run --rm microsoft/sqlcmd sqlcmd --help
#

## should be set after locale was generated, overwise triggers warnings
ENV LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" LC_ALL="en_US.UTF-8"
FROM scratch
ARG BUILD_DATE
ARG PACKAGE_VERSION

ENTRYPOINT ["/usr/bin/sqlcmd"]
LABEL maintainer="Brock Solutions" \
org.label-schema.schema-version="1.0" \
org.label-schema.vendor="Brock Solutions" \
org.label-schema.name="SQLCMD CLI" \
org.label-schema.version=$PACKAGE_VERSION \
org.label-schema.license="https://github.com/microsoft/go-sqlcmd/blob/main/LICENSE" \
org.label-schema.description="The MSSQL SQLCMD CLI tool" \
org.label-schema.url="https://github.com/microsoft/go-sqlcmd" \
org.label-schema.usage="https://docs.microsoft.com/sql/tools/sqlcmd-utility" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.docker.cmd="docker run -it brocksolutions/sqlcmd:$PACKAGE_VERSION"

COPY ./sqlcmd /usr/bin/sqlcmd

ENTRYPOINT ["sqlcmd"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
This repository contains the Dockerfile for the `brocksolutions/sqlcmd` container image. This image provides the latest version of
Microsoft's `sqlcmd` (Go) tool.

Microsoft does not (yet) distribute an official `sqlcmd` container image, so this image is built by installing the `sqlcmd` tool
into a base Debian image.
Microsoft does not currently distribute an official `sqlcmd` container image, so this image simply bundles the `sqlcmd` file into
a minimal container image.

## Available Tags

Expand All @@ -17,5 +17,5 @@ The entrypoint in the container is set to the `/usr/bin/sqlcmd`. This means you
the `sqlcmd` tool locally, and simply pass in any additional parameters you amy need. For example:

``` powershell
docker run --rm brocksolutions/sqlcmd -S myserver -U myuser -P mypassword -Q "SELECT @@VERSION"
docker run --rm brocksolutions/sqlcmd:latest -S myserver -U myuser -P mypassword -Q "SELECT @@VERSION"
```
60 changes: 0 additions & 60 deletions azure-pipelines.yml

This file was deleted.

0 comments on commit 89e5ab9

Please sign in to comment.