forked from intel/platform-aware-scheduling
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes in Dockerfile to use Golang based Image
- Loading branch information
1 parent
63d2671
commit d3758cb
Showing
3 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
FROM alpine:3.12.1 as build | ||
FROM golang:1.16-alpine as user_builder | ||
RUN adduser -D -u 10001 tas | ||
|
||
FROM golang:1.16-alpine as builder | ||
ARG DIR=telemetry-aware-scheduling | ||
ARG SRC_ROOT=/src_root | ||
COPY . ${SRC_ROOT} | ||
|
||
RUN mkdir -p /install_root/etc | ||
COPY --from=user_builder /etc/passwd /install_root/etc/passwd | ||
|
||
WORKDIR ${SRC_ROOT}/${DIR} | ||
RUN CGO_ENABLED=0 GO111MODULE=on go build -ldflags="-s -w" -o /install_root/extender ./cmd \ | ||
&& install -D ${SRC_ROOT}/${DIR}/LICENSE /install_root/usr/local/share/package-licenses/telemetry-aware-scheduling/LICENSE \ | ||
&& scripts/copy-modules-licenses.sh ./cmd /install_root/usr/local/share/ | ||
|
||
FROM scratch | ||
WORKDIR / | ||
COPY extender . | ||
COPY --from=build /etc/passwd /etc/passwd | ||
COPY --from=builder /install_root / | ||
EXPOSE 9001/tcp | ||
USER tas | ||
ENTRYPOINT ["/extender"] | ||
ENTRYPOINT ["/extender"] |
54 changes: 54 additions & 0 deletions
54
telemetry-aware-scheduling/scripts/copy-modules-licenses.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2019-2021 Intel Corporation. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Copy the license obligations of ".Deps" modules for a package to a target directory | ||
set -o errexit | ||
set -o nounset | ||
|
||
if [ $# != 2 ] || [ "$1" = "?" ] || [ "$1" = "--help" ]; then | ||
echo "Usage: $0 <package> <target dir>" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$2" ] || [ ! -w "$2" ]; then | ||
echo "Error: cannot use $2 as the target directory" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$2"/package-licenses ]; then | ||
mkdir "$2"/package-licenses | ||
fi | ||
|
||
export GO111MODULE=on | ||
|
||
if [ ! -d vendor ]; then | ||
go mod vendor -v | ||
fi | ||
|
||
LICENSE_FILES=$(find vendor |grep -e LICENSE -e NOTICE|cut -d / -f 2-) | ||
PACKAGE_DEPS=$(go list -f '{{ join .Deps "\n" }}' "$1" |grep "\.") | ||
|
||
POPD=$(pwd) | ||
cd vendor | ||
|
||
for lic in $LICENSE_FILES; do | ||
DIR=$(dirname "$lic") | ||
|
||
# Copy the license if its repository path is found in package .Deps | ||
if [ "$(echo "$PACKAGE_DEPS" | grep -c "$DIR")" -gt 0 ]; then | ||
cp --parents "$lic" "$2"/package-licenses | ||
|
||
# Copy the source if the license is MPL/GPL/LGPL | ||
if [ "$(grep -c -w -e MPL -e GPL -e LGPL "$lic")" -gt 0 ]; then | ||
if [ ! -d "$2"/package-sources ]; then | ||
mkdir "$2"/package-sources | ||
fi | ||
tar -zvcf "$2"/package-sources/"$(echo "$DIR" | tr / _)".tar.gzip "$DIR" | ||
fi | ||
fi | ||
done | ||
|
||
cd "$POPD" |