Skip to content

Commit d496eaf

Browse files
committed
Use new key import method on Ubuntu
1 parent 65635c6 commit d496eaf

File tree

2 files changed

+67
-12
lines changed

2 files changed

+67
-12
lines changed

.github/workflows/docker.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,39 @@ jobs:
5555
steps:
5656
- uses: actions/checkout@v3
5757

58+
- name: SQLServer Checksum
59+
id: sqlserver-checksum
60+
shell: bash
61+
run: |
62+
echo "checksum=$(curl --silent -L --header 'Accept: application/vnd.docker.distribution.manifest.v2+json' 'https://mcr.microsoft.com/v2/mssql/server/manifests/2022-latest' | jq -r '.config.digest')" >> $GITHUB_OUTPUT
63+
64+
- name: Cache Docker Image
65+
id: docker-image-cache
66+
uses: actions/cache@v3
67+
with:
68+
path: '*.tar'
69+
key: docker-image-cache-${{ runner.os }}-${{ steps.sqlserver-checksum.outputs.checksum }}
70+
71+
- name: Load SQLServer image
72+
if: steps.docker-image-cache.outputs.cache-hit == 'true'
73+
run: docker image load -i sqlserver.tar
74+
75+
- name: Run SQL Server
76+
run: |
77+
docker run \
78+
--pull always \
79+
-e 'ACCEPT_EULA=Y' \
80+
-e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' \
81+
-p 1433:1433 \
82+
-d \
83+
--name SQLServer \
84+
--rm \
85+
mcr.microsoft.com/mssql/server:2022-latest
86+
87+
- name: Save SQLServer image
88+
if: steps.docker-image-cache.outputs.cache-hit != 'true'
89+
run: docker image save -o sqlserver.tar mcr.microsoft.com/mssql/server:2022-latest
90+
5891
- uses: satackey/action-docker-layer-caching@v0.0.11
5992
continue-on-error: true
6093

@@ -69,11 +102,23 @@ jobs:
69102
'--build-arg=MSSQLTOOLS_PATH=${{ matrix.version.package_path }}' \
70103
.
71104
105+
- name: Wait for SQLServer to become available
106+
uses: iFaxity/wait-on-action@v1.1.0
107+
with:
108+
resource: tcp:localhost:1433
109+
timeout: 1800000
110+
interval: 5000
111+
log: true
112+
72113
- name: Test image
73114
run: |
74-
docker run -t --rm --entrypoint='' \
115+
docker run -t --rm --entrypoint='' --network=host \
75116
'${{ env.IMAGE_NAME_FULL }}' \
76-
sqlcmd -?
117+
sqlcmd -b -C -S 127.0.0.1,1433 -U sa -P 'yourStrong(!)Password' -Q 'SELECT @@VERSION'
118+
119+
- name: Stop SQLServer
120+
if: always()
121+
run: docker stop SQLServer
77122

78123
- name: Tag Minor
79124
if: "${{ matrix.version.sqlcmd_minor != '' }}"

ubuntu/Dockerfile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
ARG UBUNTU_VERSION=18.04
1+
ARG UBUNTU_VERSION=22.04
22
FROM ubuntu:$UBUNTU_VERSION
33

4-
ARG MSSQLTOOLS_VERSION=17.4.1.1-1
4+
ARG MSSQLTOOLS_VERSION=18.2.1.1
55
# Microsoft decided to have a suffix for newer versions of mssql-tools, e.g. mssql-tools18
6-
ARG MSSQLTOOLS_SUFFIX=
6+
ARG MSSQLTOOLS_SUFFIX=18
77
# and also the path changed on newer versions. It's a mess.
8-
ARG MSSQLTOOLS_PATH=/opt/mssql-tools
8+
ARG MSSQLTOOLS_PATH=/opt/mssql-tools18
9+
910
ENV PATH=$MSSQLTOOLS_PATH/bin:$PATH
1011

11-
RUN apt-get update \
12-
&& apt-get install -y curl apt-transport-https locales gnupg2 dos2unix \
12+
RUN apt-get -qqq update \
13+
&& apt-get install -y curl apt-transport-https locales gnupg2 \
14+
# Helper command to convert \r\n to \n,
15+
# since sqlcmd prints Windows line endings
16+
dos2unix \
1317
&& locale-gen "en_US.UTF-8" \
18+
\
1419
&& export `grep "VERSION_ID" /etc/os-release | sed -e 's/^VERSION_ID=\"/VERSION_ID=/' -e 's/\"$//'` \
15-
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
16-
&& curl https://packages.microsoft.com/config/ubuntu/$VERSION_ID/prod.list | tee /etc/apt/sources.list.d/msprod.list \
17-
&& apt-get update \
20+
&& mkdir -p /etc/apt/keyrings/ \
21+
&& curl --fail https://packages.microsoft.com/config/ubuntu/$VERSION_ID/prod.list | \
22+
sed -E 's#deb\s+\[#deb [signed-by=/etc/apt/keyrings/microsoft.gpg #; t; q1' | \
23+
tee /etc/apt/sources.list.d/microsoft.list \
24+
&& curl --fail https://packages.microsoft.com/keys/microsoft.asc | \
25+
gpg --verbose --yes --no-tty --batch --dearmor -o /etc/apt/keyrings/microsoft.gpg \
26+
\
27+
&& apt-get -qqq update \
1828
&& ACCEPT_EULA=Y apt-get install -y mssql-tools$MSSQLTOOLS_SUFFIX=$MSSQLTOOLS_VERSION unixodbc-dev \
19-
&& apt-get remove -y curl apt-transport-https \
29+
&& apt-get remove -y curl apt-transport-https gnupg2 \
2030
&& rm -f /etc/apt/sources.list.d/msprod.list \
2131
&& rm -rf /var/lib/apt/lists/*
2232

0 commit comments

Comments
 (0)