|
| 1 | +# |
| 2 | +# Note: This image requires an active SLES15 subscription to build. |
| 3 | +# |
| 4 | +# Thank you to our SUSE Partners for helping with this :) |
| 5 | +# |
| 6 | +# Assumptions |
| 7 | +# 1. use a matching version to the underlying build host |
| 8 | +# 2. ensure it is registered to have access to needed repos |
| 9 | +# then leveraging container-suseconnect-zypp |
| 10 | +# e.g. zypper ref |
| 11 | +# Repository 'SLE-Module-Containers12-Pool' is up to date. |
| 12 | +# Repository 'SLE-Module-Containers12-Updates' is up to date. |
| 13 | +# Repository 'SLES12-SP5-Pool' is up to date. |
| 14 | +# Repository 'SLES12-SP5-Updates' is up to date. |
| 15 | +# All repositories have been refreshed. |
| 16 | +# 3. minimize the layers by consolidating commands |
| 17 | + |
| 18 | +FROM registry.suse.com/suse/sle15:15.3 |
| 19 | + |
| 20 | +ENV ADDITIONAL_MODULES=sle-module-legacy |
| 21 | + |
| 22 | +RUN zypper install --no-confirm --no-recommends \ |
| 23 | + # install setcap to be used later |
| 24 | + # curl is needed for rpm import |
| 25 | + libcap-progs curl && \ |
| 26 | + rpm --import https://packages.microsoft.com/keys/microsoft.asc && \ |
| 27 | + zypper rm --no-confirm --clean-deps curl |
| 28 | + |
| 29 | +# consider merging the two RUNs to save ~ 40mb at the cost of caching adding the signing key |
| 30 | + |
| 31 | +# add mssql-server repo |
| 32 | +RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \ |
| 33 | + zypper refresh packages-microsoft-com-mssql-server-2019 && \ |
| 34 | + # install mssql-server |
| 35 | + zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \ |
| 36 | + # add mssql-tools repo |
| 37 | + zypper addrepo --check https://packages.microsoft.com/config/sles/15/prod.repo && \ |
| 38 | + zypper refresh packages-microsoft-com-prod && \ |
| 39 | + # install mssql-tools (consider removing to reduce size) Microsoft already maintains a separate mssql-tools image |
| 40 | + ACCEPT_EULA=Y zypper install --no-confirm --no-recommends mssql-tools && \ |
| 41 | + zypper clean --all && \ |
| 42 | + # post installation of SQL Server the mssql user/group is created |
| 43 | + # so set the right permissions to the msssql folder |
| 44 | + mkdir -p -m 770 /var/opt/mssql && \ |
| 45 | + chown -R mssql /var/opt/mssql && \ |
| 46 | + # grant sql the permissions to connect to ports <1024 as a non-root user |
| 47 | + setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \ |
| 48 | + # allow dumps from the non-root process |
| 49 | + setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \ |
| 50 | + setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \ |
| 51 | + # ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH |
| 52 | + # and other env variables that control dynamic linking |
| 53 | + mkdir -p /etc/ld.so.conf.d && \ |
| 54 | + touch /etc/ld.so.conf.d/mssql.conf && \ |
| 55 | + echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \ |
| 56 | + ldconfig |
| 57 | + |
| 58 | +EXPOSE 1433 |
| 59 | + |
| 60 | +USER mssql |
| 61 | + |
| 62 | +CMD ["/opt/mssql/bin/sqlservr"] |
0 commit comments