microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
343 stars 20 forks source link

Add Sqlpackage to MS APT repo or MSSQL image #252

Open RiverHeart opened 1 year ago

RiverHeart commented 1 year ago

Is your feature request related to a problem? Please describe. I've created a custom MSSQL container image to support 2 workflows.

1) Run container without existing database, use DACPAC to create database. 2) Attach an existing database and apply an updated DACPAC.

Sqlpackage is required to do this but not available on the base image or through Microsoft's APT repository.

Describe the solution you'd like Ideally, Sqlpackage would be added to the Microsoft APT repository as an installable package or bundled with other tools like Sqlcmd (/opt/mssql-tools/bin/sqlcmd) in the official MSSQL Docker image.

Describe alternatives you've considered The current workaround to Sqlpackage not being available is to install unzip, download the Sqlpackage zip file from Microsoft's website, extract and set it as executable. This is several lines of abstraction over what could be a simple RUN apt-get update && apt-get install sqlpackage

ErikEJ commented 1 year ago

Not sure if it helps, but it is available as a global .NET tool also

RiverHeart commented 1 year ago

@ErikEJ That was suggested to me but dotnet isn't installed on the MSSQL container. The Dockerfile I'm using is multistage and has a Dotnet 7 build stage to turn an SDK style Database project into DACPACs and copy them over to the MSSQL image. It might be possible to install the tool on the build stage and copy it over to the MSSQL image but it looks like there are a bunch of supporting files to copy instead of a single static binary.

dzsquared commented 1 year ago

At this time, there's the 2 ways to acquire SqlPackage (as noted in the comments):

  1. dotnet tool install -g microsoft.sqlpackage
  2. Manually applying the zip of sqlpackage and any dependencies, which is a handful of lines (<10) to achieve depending on the distro. Example - https://github.com/microsoft/vscode-dev-containers/blob/5a084a93b0736ea86395ac99019a5b72a00b6341/containers/dotnet-mssql/.devcontainer/mssql/installSQLtools.sh#L10

General link: https://learn.microsoft.com/sql/tools/sqlpackage/sqlpackage-download#linux

We're considering additional package managers for support in the future and appreciate you sharing your use case details!

ay-azara commented 11 months ago

At this time, there's the 2 ways to acquire SqlPackage (as noted in the comments):

1. `dotnet tool install -g microsoft.sqlpackage`

2. Manually applying the zip of sqlpackage and any dependencies, which is a handful of lines (<10) to achieve depending on the distro. Example - https://github.com/microsoft/vscode-dev-containers/blob/5a084a93b0736ea86395ac99019a5b72a00b6341/containers/dotnet-mssql/.devcontainer/mssql/installSQLtools.sh#L10

General link: https://learn.microsoft.com/sql/tools/sqlpackage/sqlpackage-download#linux

We're considering additional package managers for support in the future and appreciate you sharing your use case details!

A tool I've used in the past to make packaging in-house applications easier is https://github.com/jordansissel/fpm. It supports many package types.

yooakim commented 9 months ago

I second the wish for making sqlpackage available via APT for installation.

It would be very nice since then all I would need is to use Microsofts offocial mssql images (Debian based) and then I can simply install sqlpackage in the same way as I can install the Go version of sqlcmd

I am sore many of of us building pipelines would appreciate not having to install such a central tool as sqlpackage using download/unzip etc. So please consider making it available via apt repositories!

Here's an excerpt from a Dockerfile I use:

# Update, upgrade, and install dependencies
RUN apt-get update && apt-get install -y sqlcmd \
    && wget -O sqlpackage.zip https://aka.ms/sqlpackage-linux \
    && unzip sqlpackage.zip -d /opt/sqlpackage \
    && chmod +x /opt/sqlpackage/sqlpackage \
    && rm sqlpackage.zip \
    && rm -rf /var/lib/apt/lists/*

If sqlpackage was available via APT it could be simplified to:

# Update, upgrade, and install dependencies
RUN apt-get update && apt-get install -y sqlcmd sqlpackage \
    && rm -rf /var/lib/apt/lists/*

or even simpler would be if it was part of the mssql base images. sqlpackage and sqlcmd (preferably the Go version) belongs very close to the SQL server :-)