Skip to content

Add Microsoft SQL server adapter #100

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

Conversation

JongleurNin
Copy link
Contributor

So, Redmine now has proper support for Microsoft SQL Server, which even runs on Linux and Docker now. I attempted to add support for this, and would appreciate feedback. I'm new to this stuff.

While building the Docker images, I had problems with ha.pool.sks-keyservers.net being slow and unreliable, so I'm also proposing changes to use the MIT server instead, which worked much more reliably for me.

@JongleurNin
Copy link
Contributor Author

Hmm, that's embarrassing. I'm happy to make any changes that will allow it to pass, but may need some guidance. It appears to be failing because a download tool like wget or curl is not available to download the Phusion Passenger agent binary.

I'm guessing this is because I added wget to the buildDeps section of the Dockerfile.template file. (I had done this because I wasn't able to install the TinyTDS gem needed to support Rails bindings with Microsoft SQL server without it (that's also why I added the other build dependencies). I'll try removing wget from the build dependencies and see if that helps.

@JongleurNin
Copy link
Contributor Author

Travis doesn't seem to like the ampersand in my revised gpg command. I have it in quotes, which worked great when using Docker for Windows, but maybe that's not the best way of addressing it in a cross-platform way.

@tianon
Copy link
Member

tianon commented Dec 21, 2017

I'd recommend dropping all GPG-related changes from this PR, especially if you want it accepted. 😉

We haven't been 100% happy with ha.pool.sks-keyservers.net, but overall it's definitely more reliable than using a single server was (we used to use pgp.mit.edu, in fact). Some images have gone so far as to loop over several servers to improve build reliability (https://github.com/nginxinc/docker-nginx/blob/77e314a52b206ec18833df66e898c22658d3a486/stable/alpine/Dockerfile#L71-L81), but we didn't want to copy that pattern everywhere since we weren't entirely happy with how verbose it is. Regardless, it's not related to Microsoft SQL, so should definitely not be in this PR. 👍

3.2/Dockerfile Outdated
@@ -67,12 +67,15 @@ RUN buildDeps=' \
libsqlite3-dev \
make \
patch \
libgmp-dev \
build-essential \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using build-essential is always a red flag for me -- here's a quote from the package description (https://packages.debian.org/stretch/build-essential):

If you do not plan to build Debian packages, you don't need this package.

There are usually more specific alternatives that are more appropriate. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tested locally, and I don't think any of these package additions are necessary -- the installation works fine for me with just adding sqlserver to the list of adapters below! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I'll yank it, see what fails, and replace it with more specific packages.


if [ "$MYSQL_PORT_3306_TCP" ] && [ -z "$REDMINE_DB_MYSQL" ]; then
export REDMINE_DB_MYSQL='mysql'
elif [ "$POSTGRES_PORT_5432_TCP" ] && [ -z "$REDMINE_DB_POSTGRES" ]; then
export REDMINE_DB_POSTGRES='postgres'
elif [ "$POSTGRES_PORT_1433_TCP" ] && [ -z "$REDMINE_DB_SQLSERVER" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POSTGRES_PORT_1433_TCP here should be SQLSERVER_PORT_1433_TCP instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, I think we should remove this section -- this section is here for backwards compatibility with --link'd containers, and I don't think we need to support that for SQL Server, so this entire elif should just go away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting the copy-pasta there.

file_env 'REDMINE_DB_USERNAME' "${POSTGRES_ENV_SQLSERVER_USER:-administrator}"
file_env 'REDMINE_DB_PASSWORD' "${POSTGRES_ENV_SQLSERVER_PASSWORD}"
file_env 'REDMINE_DB_DATABASE' "${POSTGRES_ENV_SQLSERVER_DB:-${REDMINE_DB_USERNAME:-}}"
file_env 'REDMINE_DB_ENCODING' 'utf8'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example at https://www.redmine.org/projects/redmine/wiki/redmineinstall#SQL-Server for sqlserver doesn't include an encoding, so I imagine this should probably default to '' like MySQL does above, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch -- on it.

file_env 'REDMINE_DB_PORT' '1433'
file_env 'REDMINE_DB_USERNAME' "${POSTGRES_ENV_SQLSERVER_USER:-administrator}"
file_env 'REDMINE_DB_PASSWORD' "${POSTGRES_ENV_SQLSERVER_PASSWORD}"
file_env 'REDMINE_DB_DATABASE' "${POSTGRES_ENV_SQLSERVER_DB:-${REDMINE_DB_USERNAME:-}}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same deal here as above -- these should all simply default to '' since we don't need to support pulling credentials from a linked container automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm keen to understand this one better. How is this different from the MySQL or PostgreSQL case? If I go with '', will it still be possible to pass in these values when creating a Docker container based on this image?

FWIW, I myself am planning on using an external physical SQL server database, but I can see users wanting to be have the option of linking with a SQL Server container in one shot without having to mess with the database.yml file manually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone will pass them is as REDMINE_DB_USERNAME, REDMINE_DB_PASSWORD, etc (or the respective _FILE version), and we won't have a fallback to the SQLSERVER_ENV_* variables that come from the environment variables of a container linked as --link my-sqlserver:sqlserver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. So that entire section is just to establish fallbacks/defaults. Right on, I've made everything in that section '' per @tianon's feedback.

3.2/Dockerfile Outdated
' \
&& set -ex \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& bundle install --without development test \
&& for adapter in mysql2 postgresql sqlite3; do \
&& for adapter in sqlserver mysql2 postgresql sqlite3; do \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep these in the same order they are in the entrypoint, so sqlserver should go between postgresql and sqlite3. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem.

@JongleurNin JongleurNin changed the title Add Microsoft SQL server adapter, use more robust gpg keyserver Add Microsoft SQL server adapter Dec 22, 2017
@JongleurNin
Copy link
Contributor Author

Hmm, still failing, but I can't really tell what the problem is -- all gpg changes are backed out. Sample failures appear on these lines, but the image itself appears to be building correctly in the end.

3.2/Dockerfile Outdated
@@ -26,7 +26,7 @@ RUN set -x \
&& wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say the missing && is causing the build failures. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp. Thank you!


if [ "$MYSQL_PORT_3306_TCP" ] && [ -z "$REDMINE_DB_MYSQL" ]; then
export REDMINE_DB_MYSQL='mysql'
elif [ "$POSTGRES_PORT_5432_TCP" ] && [ -z "$REDMINE_DB_POSTGRES" ]; then
export REDMINE_DB_POSTGRES='postgres'
elif [ "$SQLSERVER_PORT_1433_TCP" ] && [ -z "$REDMINE_DB_SQLSERVER" ]; then
export REDMINE_DB_SQLSERVER='sqlserver'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also drop these two lines, since they are also about a linked container.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. But can you help me to understand how this is bad to include for SQL server, but good to include for PostgreSQL and MySQL?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are still there for backwards compatibility to use the presence of environment variables to detect a --linked container. Docker docs call links a legacy feature that "may eventually be removed". We should instead point users to an example compose/stack file that sets all of the correct environment variables.

@@ -67,12 +67,14 @@ RUN buildDeps=' \
libsqlite3-dev \
make \
patch \
libgmp-dev \
libc6-dev \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure these are necessary? I was able to install sqlserver successfully without them in my testing. 😕

(If they are indeed necessary, this list should stay in sorted order, but I'm not entirely convinced they are -- maybe they're pulled in already by one of the above deps?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be correct. I haven't been able to figure out how to test this locally due to a variety of Docker errors I encountered. I did have to install these packages before attempting to add support for SQL server in order to build the TinyTDS gem. I will try removing these and seeing whether the CI build passes.

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍 (and Travis is happy too 🤘)

@yosifkit yosifkit merged commit cb871da into docker-library:master Jan 2, 2018
@JongleurNin JongleurNin deleted the add-microsoft-sql-server branch January 2, 2018 23:54
@JongleurNin
Copy link
Contributor Author

Hmm, Travis was happy for me in my branch too, and I saw it succeed after your merge, but it looks like there are errors in master for 3.4 only. Hope I didn't cause you guys grief somehow!

@tianon
Copy link
Member

tianon commented Jan 3, 2018

Naw, just a standard flakey test. 👍 ❤️

tianon added a commit to infosiftr/stackbrew that referenced this pull request Jan 3, 2018
- `cassandra`: add `docker-entrypoint.sh` to PATH (docker-library/cassandra#130)
- `ghost`: 1.19.1
- `haproxy`: 1.6.14, 1.7.10
- `nextcloud`: redis-3.1.6, APCu-5.1.9
- `php`: better libs-preserving code (docker-library/php#556)
- `redmine`: add `sqlserver` database adapter (docker-library/redmine#100)
- `rocket.chat`: 0.60.3
- `wordpress`: remove `-dev` dependencies (docker-library/wordpress#267)
@JongleurNin
Copy link
Contributor Author

Thanks for merging this, @tianon! You might not read comments on closed PRs, but is there any chance the documentation at https://github.com/docker-library/docs/tree/master/redmine could also be updated so people know that SQL server is now supported and have some examples of how to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants