summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab/test.yml1
-rw-r--r--CHANGELOG.md5
-rw-r--r--Dockerfile21
-rw-r--r--Gemfile.lock2
-rwxr-xr-xbin/docker-build2
-rw-r--r--config/files/.bashrc9
-rw-r--r--config/install.sh48
-rw-r--r--lib/license/finder/ext/dotnet.rb12
-rw-r--r--lib/license/finder/ext/nuget.rb16
-rw-r--r--lib/license/management.rb3
-rw-r--r--lib/license/management/version.rb2
-rw-r--r--spec/support/proxy_helper.rb8
12 files changed, 91 insertions, 38 deletions
diff --git a/.gitlab/test.yml b/.gitlab/test.yml
index 00c9434..6d0dcae 100644
--- a/.gitlab/test.yml
+++ b/.gitlab/test.yml
@@ -35,7 +35,6 @@ lint:
variables:
GIT_DEPTH: "10"
GIT_STRATEGY: fetch
- LOG_LEVEL: debug
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2168955..38d1587 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# GitLab License management changelog
+## v3.19.0
+
+- Include the latest LTS of the .NET SDK in the Docker image. (!191)
+- Include the latest LTS of Mono in the Docker image. (!193)
+
## v3.18.1
- Fix failing composer tests.
diff --git a/Dockerfile b/Dockerfile
index a5119c3..50ee6b7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,21 @@
# syntax = docker/dockerfile:experimental
-FROM debian:stable AS deb-builder
+FROM debian:stable AS gem-builder
WORKDIR /build
COPY . ./
-RUN ./bin/omnibus setup
-RUN ./bin/omnibus build license_management
+RUN ./bin/omnibus setup && \
+ ./bin/omnibus build license_management && \
+ mkdir -p /opt/toolcache && \
+ cp pkg/*.deb /opt/toolcache/
+
+FROM debian:stable AS mono-builder
+RUN apt-get update -q
+RUN apt-get install --no-install-recommends -y apt-transport-https dirmngr gnupg ca-certificates
+RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+RUN echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list
+RUN apt-get update -q
+RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/apt.conf.d/docker-clean.bak
+RUN apt-get install -y --no-install-recommends nuget referenceassemblies-pcl ca-certificates-mono
+RUN mkdir -p /opt/toolcache && cp /var/cache/apt/archives/*.deb /opt/toolcache/
FROM debian:stable-slim
ENV ASDF_DATA_DIR="/opt/asdf"
@@ -12,7 +24,8 @@ ENV TERM="xterm"
WORKDIR /opt/gitlab
COPY config/01_nodoc /etc/dpkg/dpkg.cfg.d/01_nodoc
RUN mkdir -p /opt/toolcache
-COPY --from=deb-builder /build/pkg/*.deb /opt/toolcache/
+COPY --from=gem-builder /opt/toolcache/*.deb /opt/toolcache/
+COPY --from=mono-builder /opt/toolcache/*.deb /opt/toolcache/mono/
COPY config/install.sh /opt/install.sh
RUN bash /opt/install.sh
COPY run.sh /
diff --git a/Gemfile.lock b/Gemfile.lock
index 27474e8..b3cbb88 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -8,7 +8,7 @@ GIT
PATH
remote: .
specs:
- license-management (3.18.1)
+ license-management (3.19.0)
license_finder (~> 6.6.0)
GEM
diff --git a/bin/docker-build b/bin/docker-build
index 6f111fe..abc46c1 100755
--- a/bin/docker-build
+++ b/bin/docker-build
@@ -9,7 +9,7 @@ IMAGE_NAME=${IMAGE_NAME:-$(basename "$PWD"):latest}
export DOCKER_BUILDKIT=1
if command -v docker; then
- docker build --progress=plain --network=host --cache-from "$LATEST_IMAGE" -t "$IMAGE_NAME" .
+ docker build --network=host --cache-from "$LATEST_IMAGE" -t "$IMAGE_NAME" .
else
echo "Install docker: https://docs.docker.com/engine/installation/"
exit 1
diff --git a/config/files/.bashrc b/config/files/.bashrc
index 81afcb8..388f93d 100644
--- a/config/files/.bashrc
+++ b/config/files/.bashrc
@@ -60,7 +60,16 @@ function enable_dev_mode() {
}
inflate /opt/asdf.tar.zst /opt
+inflate /opt/gitlab/.cache.tar.zst /opt/gitlab
+inflate /opt/gitlab/.config.tar.zst /opt/gitlab
+inflate /opt/gitlab/.m2.tar.zst /opt/gitlab
+inflate /opt/gitlab/embedded.tar.zst /opt/gitlab
+inflate /usr/include.tar.zst /usr
+inflate /usr/lib/elixir.tar.zst /usr/lib
+inflate /usr/lib/erlang.tar.zst /usr/lib
inflate /usr/lib/gcc.tar.zst /usr/lib
+inflate /usr/lib/git-core.tar.zst /usr/lib
+inflate /usr/lib/llvm-7.tar.zst /usr/lib
inflate /usr/lib/rustlib.tar.zst /usr/lib
# shellcheck source=/dev/null
diff --git a/config/install.sh b/config/install.sh
index 0de9b1c..8d555c4 100644
--- a/config/install.sh
+++ b/config/install.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-set -euo pipefail
+set -exuo pipefail
export DEBIAN_FRONTEND=noninteractive
@@ -75,17 +75,8 @@ apt-get install -y --no-install-recommends \
zstd
echo -e "section_end:$(date +%s):install_packages\r\e[0K"
-echo -e "section_start:$(date +%s):install_dotnet\r\e[0K==> Installing dotnet/mono…"
-wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg
-wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/debian/10/prod.list
-apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
-echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list
-
-curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
-echo -e "section_end:$(date +%s):install_dotnet\r\e[0K"
-
echo -e "section_start:$(date +%s):install_asdf\r\e[0K==> Installing asdf…"
-dpkg --install "$(find /opt/toolcache/ -name "license-management*.deb")"
+dpkg --install /opt/toolcache/license*.deb
rm -fr /root
ln -s /opt/gitlab /root
@@ -113,6 +104,17 @@ done
wait
echo -e "section_end:$(date +%s):install_asdf\r\e[0K"
+echo -e "section_start:$(date +%s):install_dotnet\r\e[0K==> Installing dotnet/mono…"
+wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg
+wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/debian/10/prod.list
+apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list
+
+curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
+curl -o /tmp/dotnet-install.sh https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.sh
+bash /tmp/dotnet-install.sh --install-dir /opt/asdf/installs/dotnet/latest --channel LTS --version latest
+echo -e "section_end:$(date +%s):install_dotnet\r\e[0K"
+
echo -e "section_start:$(date +%s):cleanup\r\e[0K==> Beginning cleanup…"
apt purge -y libx11-6 libwayland-client0
apt autoremove -y
@@ -180,15 +182,35 @@ zstd_command="/usr/bin/zstd -19 -T0"
cd /opt
tar --use-compress-program "$zstd_command" -cf /opt/asdf.tar.zst asdf &
-cd /usr/lib
-tar --use-compress-program "$zstd_command" -cf /usr/lib/gcc.tar.zst gcc &
+cd /opt/gitlab
+tar --use-compress-program "$zstd_command" -cf /opt/gitlab/.cache.tar.zst .cache &
+tar --use-compress-program "$zstd_command" -cf /opt/gitlab/.config.tar.zst .config &
+tar --use-compress-program "$zstd_command" -cf /opt/gitlab/.m2.tar.zst .m2 &
+tar --use-compress-program "$zstd_command" -cf /opt/gitlab/embedded.tar.zst embedded &
+
+cd /usr
+tar --use-compress-program "$zstd_command" -cf /usr/include.tar.zst include &
cd /usr/lib
+tar --use-compress-program "$zstd_command" -cf /usr/lib/elixir.tar.zst elixir &
+tar --use-compress-program "$zstd_command" -cf /usr/lib/erlang.tar.zst erlang &
+tar --use-compress-program "$zstd_command" -cf /usr/lib/gcc.tar.zst gcc &
+tar --use-compress-program "$zstd_command" -cf /usr/lib/git-core.tar.zst git-core &
+tar --use-compress-program "$zstd_command" -cf /usr/lib/llvm-7.tar.zst llvm-7 &
tar --use-compress-program "$zstd_command" -cf /usr/lib/rustlib.tar.zst rustlib &
wait
rm -fr \
/opt/asdf/ \
+ /opt/gitlab/.m2 \
+ /opt/gitlab/.cache \
+ /opt/gitlab/.config \
+ /opt/gitlab/embedded \
+ /usr/include \
+ /usr/lib/elixir \
+ /usr/lib/erlang \
/usr/lib/gcc \
+ /usr/lib/git-core \
+ /usr/lib/llvm-7 \
/usr/lib/rustlib
echo -e "section_end:$(date +%s):compress_files\r\e[0K"
diff --git a/lib/license/finder/ext/dotnet.rb b/lib/license/finder/ext/dotnet.rb
index c5ff485..d2cb998 100644
--- a/lib/license/finder/ext/dotnet.rb
+++ b/lib/license/finder/ext/dotnet.rb
@@ -9,17 +9,19 @@ module LicenseFinder
project_path.glob('*.fsproj')
end
+ def installed?(*)
+ File.exist?('/opt/asdf/installs/dotnet/latest/dotnet')
+ end
+
def prepare
- shell.execute(['apt-get', :update, '-q'])
- shell.execute(['apt-get', :install, '-y', '--no-install-recommends', 'dotnet-sdk-3.1'])
shell.execute([:mkdir, '-p', vendor_path.to_s]) unless vendor_path.exist?
shell.execute([
- :dotnet,
+ '/opt/asdf/installs/dotnet/latest/dotnet',
:restore, detected_package_path.to_s,
+ '--locked-mode',
'--no-cache',
'--packages', vendor_path.to_s,
- '--locked-mode',
- '--verbosity', :detailed
+ '--verbosity', :normal
])
end
diff --git a/lib/license/finder/ext/nuget.rb b/lib/license/finder/ext/nuget.rb
index 6fb2553..93985ba 100644
--- a/lib/license/finder/ext/nuget.rb
+++ b/lib/license/finder/ext/nuget.rb
@@ -3,22 +3,24 @@
module LicenseFinder
class Nuget
def prepare
- shell.execute(['apt-get', :update, '-q'])
- shell.execute(['apt-get', :install, '-y', '--no-install-recommends', 'mono-complete'])
+ shell.execute(['apt-get', :install, '-y', '/opt/toolcache/mono/*.deb'])
shell.execute([:mkdir, '-p', vendor_path.to_s]) unless vendor_path.exist?
-
Dir.chdir(project_path) do
shell.execute([
:mono, '/usr/local/bin/nuget.exe',
:restore, detected_package_path,
- '-Verbosity detailed',
- '-PackagesDirectory', vendor_path,
+ '-LockedMode',
'-NoCache',
- '-LockedMode'
+ '-PackagesDirectory', vendor_path,
+ '-Verbosity', :normal
])
end
end
+ def installed?(*args)
+ File.exist?('/usr/local/bin/nuget.exe')
+ end
+
def current_packages
dependencies.map do |dependency|
nupkg = vendor_path.glob("**/#{dependency.name}*.nupkg")[0]
@@ -45,6 +47,8 @@ module LicenseFinder
[]
end
+ private
+
def vendor_path
@vendor_path ||= Pathname.pwd.join('.gitlab', 'cache', 'vendor')
end
diff --git a/lib/license/management.rb b/lib/license/management.rb
index 58310f7..0824157 100644
--- a/lib/license/management.rb
+++ b/lib/license/management.rb
@@ -26,7 +26,8 @@ module License
def self.logger
@logger ||= Logger.new(STDOUT, level: ENV.fetch('LOG_LEVEL', Logger::WARN)).tap do |x|
x.formatter = proc do |_severity, _datetime, _progname, message|
- "[v#{VERSION}] #{message}\n"
+ prefix = message.start_with?("\n") ? "" : "[v#{VERSION}] "
+ "#{prefix}#{message}\n"
end
end
end
diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb
index 1ba7279..72c1491 100644
--- a/lib/license/management/version.rb
+++ b/lib/license/management/version.rb
@@ -2,6 +2,6 @@
module License
module Management
- VERSION = '3.18.1'
+ VERSION = '3.19.0'
end
end
diff --git a/spec/support/proxy_helper.rb b/spec/support/proxy_helper.rb
index 700fe38..a07ee84 100644
--- a/spec/support/proxy_helper.rb
+++ b/spec/support/proxy_helper.rb
@@ -5,11 +5,9 @@ module ProxyHelper
def generate_self_signed_certificate_for(host)
Dir.chdir License::Management.root.join('tmp') do
- system([
- "rm -f #{host}.*",
- "/usr/bin/openssl req -x509 -newkey rsa:4096 -keyout #{host}.key -out #{host}.crt -days 999 -nodes -subj '/C=/ST=/L=/O=/OU=/CN=*.test' -addext 'subjectAltName=DNS:nuget.test,DNS:rubygems.test,DNS:goproxy.test'",
- "cat #{host}.* > #{host}.pem"
- ].join("&&"))
+ system("rm -f #{host}.*")
+ system("/usr/bin/openssl req -x509 -newkey rsa:4096 -keyout #{host}.key -out #{host}.crt -days 999 -nodes -subj '/C=/ST=/L=/O=/OU=/CN=*.test' -addext 'subjectAltName=DNS:nuget.test,DNS:rubygems.test,DNS:goproxy.test'")
+ system("cat #{host}.* > #{host}.pem")
end
end