Add makefile and scripts and updated build script
This commit is contained in:
22
src/build.sh
22
src/build.sh
@@ -4,7 +4,11 @@
|
||||
# MIT
|
||||
#
|
||||
|
||||
# Catch errors
|
||||
set -ex
|
||||
|
||||
# Default args
|
||||
DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-calpine-os-linux}
|
||||
DOCKER_USERNAME="${DOCKER_USERNAME:-cubetiq}"
|
||||
ALPINE_VERSION="${ALPINE_VERSION:-3.13.3}"
|
||||
PACKAGES="apk-tools ca-certificates ssl_client"
|
||||
@@ -19,6 +23,9 @@ mkdir $DOCKER_ROOT
|
||||
MS_ROOT="${DOCKER_ROOT}/../microscanner"
|
||||
mkdir $MS_ROOT
|
||||
|
||||
# Load pre-install
|
||||
$PRE_INSTALL
|
||||
|
||||
# Build from alpine rootfs
|
||||
# Download rootfs builder and verify it.
|
||||
wget https://raw.githubusercontent.com/alpinelinux/alpine-make-rootfs/v0.5.1/alpine-make-rootfs -O "$MKROOTFS"
|
||||
@@ -35,21 +42,22 @@ sudo ${MKROOTFS} --mirror-uri http://dl-2.alpinelinux.org/alpine \
|
||||
# Create Dockerfile
|
||||
cat <<DOCKERFILE > "${DOCKER_ROOT}/Dockerfile"
|
||||
FROM scratch
|
||||
USER worker
|
||||
USER cubetiq
|
||||
ADD $(basename $BUILD_TAR) /
|
||||
CMD ["/bin/sh"]
|
||||
DOCKERFILE
|
||||
|
||||
cd $DOCKER_ROOT
|
||||
docker build --no-cache -t "${DOCKER_USERNAME}/alpine:${ALPINE_VERSION}" .
|
||||
docker build --no-cache -t "${DOCKER_USERNAME}/${DOCKER_IMAGE_NAME}:${ALPINE_VERSION}" .
|
||||
cd -
|
||||
|
||||
docker build --build-arg BASE_IMAGE="${DOCKER_USERNAME}/alpine:${ALPINE_VERSION}" --build-arg MS_TOKEN="${MS_TOKEN}" - <<'DOCKERFILE'
|
||||
# Scanner for docker build docker for security for os container
|
||||
docker build --build-arg BASE_IMAGE="${DOCKER_USERNAME}/${DOCKER_IMAGE_NAME}:${ALPINE_VERSION}" --build-arg MS_TOKEN="${MS_TOKEN}" - <<'DOCKERFILE'
|
||||
ARG BASE_IMAGE
|
||||
FROM $BASE_IMAGE
|
||||
ARG MS_TOKEN
|
||||
RUN wget https://get.aquasec.com/microscanner -O /home/worker/microscanner \
|
||||
&& echo "8e01415d364a4173c9917832c2e64485d93ac712a18611ed5099b75b6f44e3a5 /home/worker/microscanner" | sha256sum -c - \
|
||||
&& chmod +x /home/worker/microscanner \
|
||||
&& /home/worker/microscanner $MS_TOKEN
|
||||
RUN wget https://get.aquasec.com/microscanner -O /home/cubetiq/microscanner \
|
||||
&& echo "8e01415d364a4173c9917832c2e64485d93ac712a18611ed5099b75b6f44e3a5 /home/cubetiq/microscanner" | sha256sum -c - \
|
||||
&& chmod +x /home/cubetiq/microscanner \
|
||||
&& /home/cubetiq/microscanner $MS_TOKEN
|
||||
DOCKERFILE
|
||||
@@ -17,4 +17,4 @@ update-ca-certificates
|
||||
/sbin/apk upgrade
|
||||
|
||||
# Add a standard user.
|
||||
adduser -D -u1000 worker
|
||||
adduser -D -u1000 cubetiq
|
||||
Reference in New Issue
Block a user