-
-
Notifications
You must be signed in to change notification settings - Fork 158
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! It's a great addition. I haven't actually tried it out yet, but will on the next round. If you know other people that use sqlsrv it would be great to get them to review also.
``` | ||
Host: sqlsrv | ||
User: sa | ||
Password: password! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the mysql and postgres db setups use db
as username and password, could we use that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use the password "db" as it would fail the restrictions set by SQL Server. See: https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but could use the username 'db' true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default user on SQL Server is the user "sa". I think it stands for "system administrator", a.k.a. the root user on linux. An other user needs to be created with the SQL string "CREATE USER 'db' WITH PASSWORD 'db'". Is that what you would like to do? In this way we can also create the database "db".
Host: sqlsrv | ||
User: sa | ||
Password: password! | ||
Database: master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it important for it to be named "master"? Again, the default mysql and postgres setups use "db" for the name of the primary database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not need to be master, it is only the default database for SQL Server. The "db" database needs to be created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah if 'master' is default database then it makes sense to use it.
|
||
## Installing the PHP extensions | ||
|
||
The PHP extensions for SQL Server CANNOT be installed by adding them to the `webimage_extra_packages` setting. The problem is that they are not available as a Debian or any other distribution package. The 2 extensions (`sqlsrv` and `pdo_sqlsrv`) need to be compiled and this needs to be done after PHP is installed on the webimage. The following commands need to be copied to the end of the main `config.yaml` file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do this with a .ddev/web-build/Dockerfile instead - it's far more efficient (only has to be done once, instead of on every ddev start
. It's also easier to understand and maintain. https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-dockerfiles-for-webimage-and-dbimage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to do that, only when I did that there was no PHP installed yet, therefor it failed. Maybe I did something wrong or there is a way to do it after PHP is installed. For me, I was fantastic that I got it to work in the first place. It took me 2 weeks to get it to work. I just wanted to fix some bugs in the Drupal module sqlsrv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be happy to help with this of course. And appreciate you sharing the work that you did!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thing for me was to make it a lot easier for the people after me that would like to use DDEV with SQL Server. For some reason the PHP extension for SQL Server are not available as packages. Really annoying!
I appreciate your help with this very much!
- sqlsrv:sqlsrv | ||
|
||
volumes: | ||
sqlsystem: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ddev delete
can only delete the one volume with the name of the service. Is there a way to get all these on a single volume? It would be better that way...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am more of a programmer than somebody who does production. Therefor if you think that is best then please do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't about programming, it's about where the mounts are. Since I know nothing about sqlsrv, I don't know why you are using volumes for all these things. Is is possible that only the database is actually required to be persistent, and that's sqldata, and it could be called sqlsrv? You only need the volumes for stuff that's persistent. On mysql and postgres, that's just the database itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the SQL Server docker file. Removed the other volumes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks!
Co-authored-by: Randy Fay <randy@randyfay.com>
Co-authored-by: Randy Fay <randy@randyfay.com>
Co-authored-by: Randy Fay <randy@randyfay.com>
Co-authored-by: Randy Fay <randy@randyfay.com>
Co-authored-by: Randy Fay <randy@randyfay.com>
…volume on the SQL Server.
…m, sqllog and sqlbackup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for being so slow on this.It's a valuable contribution and I look forward to getting it in.
- I'm not clear where the docker image is coming from. I guess not from dockerhub, but I am able to do a
docker pull
on it. But the parent repo doesn't seem to have any particular information, so makes me wonder. - I'm pretty sure this image is amd64 only, so it won't work reliably with mac M1 or other arm64 machines. Please add that caveat in there.
- Most importantly: Installing the needed packages with post-start hooks is terribly painful and slow, please don't do that. Please change that into a .ddev/web-build/Dockerfile so it only happens once and doesn't have to be done on every
ddev start
.
I'll try to be more responsive when you update this, and I'll be happy to help you with any issues you run across getting the Dockerfile going. But see https://ddev.readthedocs.io/en/latest/users/extend/customizing-images/#adding-extra-dockerfiles-for-webimage-and-dbimage
Updated docker-compose.sqlsrv.yaml with comment aboutthe fact that the image does not work on Apple M1 hardware. See: microsoft/mssql-docker#734.
For: "I'm not clear where the docker image is coming from. I guess not from dockerhub, but I am able to do a docker pull on it. But the parent repo doesn't seem to have any particular information, so makes me wonder." For: "I'm pretty sure this image is amd64 only, so it won't work reliably with mac M1 or other arm64 machines. Please add that caveat in there." For: "Most importantly: Installing the needed packages with post-start hooks is terribly painful and slow, please don't do that. Please change that into a .ddev/web-build/Dockerfile so it only happens once and doesn't have to be done on every ddev start." |
Unfortunately, it looks to me like Microsoft doesn't have msodbcsql17 or mssql-tools in their Debian 11 Bullseye repository. This is what I was working on, but got stuck with
ARG BASE_IMAGE
FROM $BASE_IMAGE
ENV PATH="${PATH}:/opt/mssql-tools/bin"
RUN curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl -sSL -o /etc/apt/sources.list.d/mssql-release.list https://packages.microsoft.com/config/debian/11/prod.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests apt-utils build-essential dialog php-pear php-dev unixodbc-dev
RUN ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get install -y msodbcsql17 mssql-tools
RUN pecl channel-update pecl.php.net && pecl install sqlsrv && pecl install pdo_sqlsrv
RUN for v in 7.3 7.4 8.0 8.1; do \
echo 'extension=sqlsrv.so' >> /etc/php/${v}/mods-available/sqlsrv.ini"; \
echo 'extension=pdo_sqlsrv.so' >> /etc/php/${v}/mods-available/pdo_sqlsrv.ini" ; \
done
RUN phpenmod sqlsrv pdo_sqlsrv It's easy enough to work these through one at a time just using a debian image, that's what I did. Happy to carry on from here if you know how to get msodbcsql17 and mssql-tools on Debian 11. |
Looks like no debian 11 yet... https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#debian17 ? Also https://github.com/MicrosoftDocs/sql-docs/issues/6884 Release notes are at https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/release-notes-odbc-sql-server-linux-mac?view=sql-server-ver15 - they seem to expect a release in January, so maybe we'll have it soon. |
Support for Debian 11 is in! |
About #2: When I build a container with the command A also got a new problem. It is working fine when I set the
When I run
Any idea how to fix this? @rfay: As always thank you very much for your help. It is very much appreciated. |
Thanks for the hard work on this. MS is not known for their Debian packaging skills, as we all know. Could you please link to their instructions on how to do the debian package installation? That will help for us to try to work with this. |
I have created a ticket on the MS PHP driver project. |
I followed up in microsoft/msphpsql#1377 but note that the current Dockerfile you have here isn't related to their current instructions. Note that packages.microsoft.com isn't being used at all any more, nothing is being installed with apt-get, it's all pecl. |
BTW, I learned how to get appropriate output in a complex Dockerfile situation. After a cd .ddev
docker-compose -f .ddev-docker-compose-full.yaml build
# Optionally docker-compose -f .ddev-docker-compose-full.yaml build --no-cache |
Thank you, that is very helpful information. No more, debugging in the dark. |
I might be wrong, but I didn't see links to the sqlsrv repo and the linux installation instructions in your readme. Please just make sure they're provided... for the future. |
Added the 2 requested links. |
Are you seeing a path forward on this? |
We can do the MR with a release for PHP 8.1 only and a followup for once microsoft/msphpsql#1377 is fixed. Or we can wait until the blocker is fixed. @rfay what do you think is best? |
If that works for you, it's a step forward, just document that it's php8.1 only and move forward. |
Is it possible to have it supporting PHP 7.3? |
User @absci has replied in microsoft/msphpsql#1377 with how to change the used PHP version. @rfay I have updated the Dockerfile as requested. @truls1502: I think that you could use PHP version 7.3, but I have not tested it. |
OK, if you're ready for this and want to bring it in and you think the README shows enough info, we can pull it. I haven't taken another look, but as much time as you've spent on it I imagine it's. I'd love to see it turned into a ddev-get add-on so it's easiest for people, but I'm not sure how much demand there is for sqlsrv, but there is some. |
@rfay For me it is ready to be merged. Thanks for all your help with this MR. |
Thanks, hope you'll consider converting this into a ddev-addon, https://ddev.readthedocs.io/en/latest/users/extend/additional-services/#additional-service-configurations-for-ddev - it will make it loads easier to maintain, and certainly make it available to more people. |
@drupal-daffie Following the current instructions in the readme.md https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/sqlsrv I am getting a phpize error, Is there something maybe missing form that Readme? Only thing I deviated from was setting it to PHP7.3 but I got the same error when it was PHP 8.0
|
Got past the error by modifying line 13 of https://github.com/drud/ddev-contrib/blob/e8eb363487d764738e48fb41ee4177d473b1fd40/docker-compose-services/sqlsrv/Dockerfile#L13 to |
Please do a PR @NickStees , also explain about how you did it with 7.3 in the README. Thanks! |
Thanks will do, I still don't have anything completely working yet, but when I do ill put it all together in a PR. |
It would be great to see this turned into a ddev-get add-on, with configurable PHP version. |
@rfay Wish I knew how to make it an Add-on, yeah I was thinking why is the PHP version hard coded in that Dockerfile when I was following the readme. |
|
On it. |
The New Solution/Problem/Issue/Bug:
Add support for the Microsoft SQL Server
How this PR Solves The Problem:
This PR add that support
Manual Testing Instructions:
Follow the comments in the readme file and the docker-compose file.
Related Issue Link(s):