Skip to content

feat: upgrade Dockerfile to Debian 12, update add-on files from upstream, fixes #24, fixes #33, fixes #35 #37

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 8 commits into from
Apr 10, 2025
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
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🐞 Bug report or Support Request
description: Create a report to help us improve.
labels: [bug]
body:
- type: checkboxes
attributes:
label: Preliminary checklist
description: Please complete the following checks before submitting an issue.
options:
- label: I am using the latest stable version of DDEV
required: true
- label: I am using the latest stable version of this add-on
required: true
- type: textarea
attributes:
label: Expected Behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
attributes:
label: Actual Behavior
description: What actually happened instead?
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Specific steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run `...`
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Screenshots? Anything that will give us more context about your issue!

💡 Attach images or log files by clicking this area to highlight it and dragging files in.
validations:
required: false
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 🚀 Feature request
description: Suggest an idea for this project.
labels: [enhancement]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search existing issues to see if one already exists for your request.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Is your feature request related to a problem?
description: Clearly and concisely describe the problem. (Ex. I'm always frustrated when...)
validations:
required: true
- type: textarea
attributes:
label: Describe your solution
description: Clearly and concisely describe what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives
description: Clearly and concisely describe any alternative solutions or features you've considered.
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request.
validations:
required: false
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## The Issue

- #<issue number>

<!-- Provide a brief description of the issue. -->

## How This PR Solves The Issue

## Manual Testing Instructions

```bash
ddev add-on get https://github.com/<user>/<repo>/tarball/<branch>
ddev restart
```

## Automated Testing Overview

<!-- Please describe the tests introduced by this PR, or explain why no tests are needed. -->

## Release/Deployment Notes

<!-- Does this affect anything else or have ramifications for other code? Does anything have to be done on deployment? -->
20 changes: 6 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@ on:
required: false
default: false

# Required permissions for keep-alive, used by ddev/github-action-add-on-test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# This is required for "gautamkrishnar/keepalive-workflow", see "ddev/github-action-add-on-test"
permissions:
actions: write

defaults:
run:
shell: bash

jobs:
tests:
defaults:
run:
shell: bash

strategy:
matrix:
ddev_version: [stable, HEAD]
fail-fast: false

# We need to use the ubuntu-20.04 image because the sqlsrv service uses the
# mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 image.
# See the issue https://github.com/ddev/ddev-sqlsrv/issues/29 for more
# details.
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: ddev/github-action-add-on-test@v2
Expand Down
92 changes: 57 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[![tests](https://github.com/ddev/ddev-sqlsrv/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-sqlsrv/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2024.svg)
[![tests](https://github.com/ddev/ddev-sqlsrv/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/ddev/ddev-sqlsrv/actions/workflows/tests.yml?query=branch%3Amain)
[![last commit](https://img.shields.io/github/last-commit/ddev/ddev-sqlsrv)](https://github.com/ddev/ddev-sqlsrv/commits)
[![release](https://img.shields.io/github/v/release/ddev/ddev-sqlsrv)](https://github.com/ddev/ddev-sqlsrv/releases/latest)

# ddev-sqlsrv <!-- omit in toc -->
# DDEV SQLSRV

* [What is ddev-sqlsrv?](#what-is-ddev-sqlsrv)
* [Components of the repository](#components-of-the-repository)
* [Getting started](#getting-started)

## What is ddev-sqlsrv?
## Overview

This add-on quickly installs the MS SQL server into a DDEV project.
It is based on the [mcr.microsoft.com/mssql/server](https://hub.docker.com/_/microsoft-mssql-server) image.
Expand All @@ -18,37 +16,25 @@ Some workarounds are described in the following threads:

## Installation

**Due to lack of upstream support, this add-on can only be used with amd64 machines, and is not usable on arm64 machines like Apple Silicon computers.**

For DDEV v1.23.5 or above run
> [!WARNING]
> Due to lack of upstream support, this add-on can only be used with amd64 machines, and is not usable on arm64 machines like Apple Silicon computers.
> (You can try installing it on Rosetta using `DDEV_IGNORE_ARCH_CHECK=true ddev add-on get ddev/ddev-sqlsrv`)

```bash
ddev add-on get ddev/ddev-sqlsrv
```

For earlier versions of DDEV run

```bash
ddev get ddev/ddev-sqlsrv
```

Then restart your project

```bash
ddev restart
```

If your project already has a `.ddev/.env` file, you need to add the following lines to it:
After installation, make sure to commit the `.ddev` directory to version control.

```dotenv
MSSQL_EXTERNAL_PORT=1433
MSSQL_SA_PASSWORD=Password12!
MSSQL_PID=Evaluation
MSSQL_DB_NAME=master
MSSQL_HOST=sqlsrv
```
## Usage

| Command | Description |
| ------- | ----------- |
| `ddev sqlcmd` | For Transact-SQL statements, system procedures, and script files |
| `ddev drupal-regex` | For compatibility with Drupal version 9 or higher |

## Drupal Notice
### Drupal Notice

Drupal CMS needs the database function installed that is mimicking the Regex function as Drupal requires. As a one-time setup for Drupal, install the database function by running the following command from your project's directory:

Expand All @@ -71,14 +57,48 @@ ddev composer require drupal/sqlsrv
**There is an open issue for Drupal 9.4+ installations. Until merged, you need to apply [patch #4](https://www.drupal.org/project/sqlsrv/issues/3291199#comment-14576456), see [Call to a member function fetchField() on null
](https://www.drupal.org/project/sqlsrv/issues/3291199)**

## Manually enabling MySQL/MariaDB
### Manually enabling MySQL/MariaDB/PostgreSQL

**This addons disables the default database by automatically adding `omit_containers: [db,dba]` in the `config.sqlsrv.yaml`**
**This addons disables the default database by automatically adding `omit_containers: [db]` in the `config.sqlsrv.yaml`**

If your project needs to use both MariaDB and MS SQL Server databases, you have to remove `#ddev-generated` and
`omit_containers: [db,dba]` from `config.sqlsrv.yaml`.
`omit_containers: [db]` from `config.sqlsrv.yaml`.

See [Config Options](https://ddev.readthedocs.io/en/stable/users/configuration/config/) for additional notes.

## Advanced Customization

Use a different port:

See [.ddev/config.yaml Options](https://ddev.readthedocs.io/en/stable/users/extend/config_yaml/) for additional notes.
```bash
ddev dotenv set .ddev/.env.sqlsrv --mssql-external-port=1434
ddev add-on get ddev/ddev-sqlsrv
ddev restart
```

Make sure to commit the `.ddev/.env.sqlsrv` file to version control.

Or change the password:

```bash
ddev dotenv set .ddev/.env.sqlsrv --mssql-sa-password='myNewPassword'
ddev add-on get ddev/ddev-sqlsrv
ddev restart
```

Make sure to commit the `.ddev/.env.sqlsrv` file to version control.

All customization options (use with caution):

| Variable | Flag | Default |
| -------- | ---- | ------- |
| `MSSQL_DOCKER_IMAGE` | `--mssql-docker-image` | `mcr.microsoft.com/mssql/server:2022-CU17-ubuntu-22.04` |
| `MSSQL_EXTERNAL_PORT` | `--mssql-external-port` | `1433` |
| `MSSQL_SA_PASSWORD` | `--mssql-sa-password` | `Password12!` |
| `MSSQL_PID` | `--mssql-pid` | `Evaluation` |
| `MSSQL_DB_NAME` | `--mssql-db-name` | `master` |
| `MSSQL_HOST` | `--mssql-host` | `sqlsrv` |
| `MSSQL_COLLATION` | `--mssql-collation` | `LATIN1_GENERAL_100_CI_AS_SC_UTF8` |

## Links with useful information

Expand All @@ -94,6 +114,8 @@ See [.ddev/config.yaml Options](https://ddev.readthedocs.io/en/stable/users/exte
* [Drupal's module for the SQL Server](https://www.drupal.org/project/sqlsrv)
* [Github MS drivers for PHP](https://github.com/microsoft/msphpsql)

Note that more advanced techniques are discussed in [DDEV docs](https://ddev.readthedocs.io/en/latest/users/extend/additional-services/#additional-service-configurations-and-add-ons-for-ddev).
Note that more advanced techniques are discussed in [DDEV docs](https://ddev.readthedocs.io/en/stable/users/extend/additional-services/).

## Credits

**Contributed and maintained by [@robertoperuzzo](https://github.com/robertoperuzzo) based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/sqlsrv) by [drupal-daffie](https://github.com/drupal-daffie)**
8 changes: 4 additions & 4 deletions commands/sqlsrv/drupal-regex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

## #ddev-generated
## Description: Installs the Regex database function for compatibility with Drupal version 9 or higher.
Expand All @@ -14,8 +14,8 @@ then
fi

# The following are changed to allow the installation and execution of the user provided database function.
/opt/mssql-tools/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -d ${MSSQL_DB_NAME} -Q 'EXEC sp_configure "show advanced options", 1; RECONFIGURE; EXEC sp_configure "clr strict security", 0; RECONFIGURE; EXEC sp_configure "clr enable", 1; RECONFIGURE;'
/opt/mssql-tools18/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -C -d ${MSSQL_DB_NAME} -Q 'EXEC sp_configure "show advanced options", 1; RECONFIGURE; EXEC sp_configure "clr strict security", 0; RECONFIGURE; EXEC sp_configure "clr enable", 1; RECONFIGURE;'

# Create the assambly and the function for the Regex helper.
/opt/mssql-tools/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -d ${MSSQL_DB_NAME} -Q 'CREATE ASSEMBLY Regex from "/RegEx.dll" WITH PERMISSION_SET = SAFE'
/opt/mssql-tools/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -d ${MSSQL_DB_NAME} -Q 'CREATE FUNCTION dbo.REGEXP(@pattern NVARCHAR(100), @matchString NVARCHAR(100)) RETURNS bit EXTERNAL NAME Regex.RegExCompiled.RegExCompiledMatch'
/opt/mssql-tools18/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -C -d ${MSSQL_DB_NAME} -Q 'CREATE ASSEMBLY Regex from "/RegEx.dll" WITH PERMISSION_SET = SAFE'
/opt/mssql-tools18/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -C -d ${MSSQL_DB_NAME} -Q 'CREATE FUNCTION dbo.REGEXP(@pattern NVARCHAR(100), @matchString NVARCHAR(100)) RETURNS bit EXTERNAL NAME Regex.RegExCompiled.RegExCompiledMatch'
4 changes: 2 additions & 2 deletions commands/sqlsrv/sqlcmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash

## #ddev-generated
## Description: The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files.
## Usage: sqlcmd
## Example: "ddev sqlcmd"

/opt/mssql-tools/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -d ${MSSQL_DB_NAME}
/opt/mssql-tools18/bin/sqlcmd -P ${MSSQL_SA_PASSWORD} -U SA -C -d ${MSSQL_DB_NAME} $@
6 changes: 3 additions & 3 deletions config.sqlsrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ disable_settings_management: true
omit_containers: [db]

hooks:
post-start:
- exec: echo export PATH="$PATH:/opt/mssql-tools/bin" >> ~/.bashrc
- exec: source ~/.bashrc
post-start:
- exec: echo export PATH="$PATH:/opt/mssql-tools18/bin" >> ~/.bashrc
- exec: source ~/.bashrc
Loading