Add makefile and scripts and updated build script

This commit is contained in:
Sambo Chea 2021-03-26 10:15:40 +07:00
parent 9b48bbe4df
commit e7b34d4d23
4 changed files with 29 additions and 8 deletions

View File

@ -0,0 +1,9 @@
DOCKER_IMAGE_NAME = calpine-os-linux
DOCKER_IMAGE_VERSION = 3.13.3
DOCKER_IMAGE_SIZE = $(shell docker images --format "{{.Repository}} {{.Size}}" | grep $(DOCKER_IMAGE_NAME) | cut -d\ -f2)
build:
$(shell ./src/build.sh)
@echo "Size of the image: ${DOCKER_IMAGE_SIZE}"
.PHONY: build

View File

@ -3,5 +3,9 @@
- Minimal container image
- Easy and fast runtime for serverless
# Build
```shell
make build
```
# Contributors
- Sambo Chea <sombochea@cubetiqs.com>

View File

@ -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

View File

@ -17,4 +17,4 @@ update-ca-certificates
/sbin/apk upgrade
# Add a standard user.
adduser -D -u1000 worker
adduser -D -u1000 cubetiq