Add makefile and scripts and updated build script
This commit is contained in:
parent
9b48bbe4df
commit
e7b34d4d23
9
Makefile
9
Makefile
@ -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
|
@ -3,5 +3,9 @@
|
|||||||
- Minimal container image
|
- Minimal container image
|
||||||
- Easy and fast runtime for serverless
|
- Easy and fast runtime for serverless
|
||||||
|
|
||||||
|
# Build
|
||||||
|
```shell
|
||||||
|
make build
|
||||||
|
```
|
||||||
# Contributors
|
# Contributors
|
||||||
- Sambo Chea <sombochea@cubetiqs.com>
|
- Sambo Chea <sombochea@cubetiqs.com>
|
22
src/build.sh
22
src/build.sh
@ -4,7 +4,11 @@
|
|||||||
# MIT
|
# MIT
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Catch errors
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
# Default args
|
||||||
|
DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-calpine-os-linux}
|
||||||
DOCKER_USERNAME="${DOCKER_USERNAME:-cubetiq}"
|
DOCKER_USERNAME="${DOCKER_USERNAME:-cubetiq}"
|
||||||
ALPINE_VERSION="${ALPINE_VERSION:-3.13.3}"
|
ALPINE_VERSION="${ALPINE_VERSION:-3.13.3}"
|
||||||
PACKAGES="apk-tools ca-certificates ssl_client"
|
PACKAGES="apk-tools ca-certificates ssl_client"
|
||||||
@ -19,6 +23,9 @@ mkdir $DOCKER_ROOT
|
|||||||
MS_ROOT="${DOCKER_ROOT}/../microscanner"
|
MS_ROOT="${DOCKER_ROOT}/../microscanner"
|
||||||
mkdir $MS_ROOT
|
mkdir $MS_ROOT
|
||||||
|
|
||||||
|
# Load pre-install
|
||||||
|
$PRE_INSTALL
|
||||||
|
|
||||||
# Build from alpine rootfs
|
# Build from alpine rootfs
|
||||||
# Download rootfs builder and verify it.
|
# Download rootfs builder and verify it.
|
||||||
wget https://raw.githubusercontent.com/alpinelinux/alpine-make-rootfs/v0.5.1/alpine-make-rootfs -O "$MKROOTFS"
|
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
|
# Create Dockerfile
|
||||||
cat <<DOCKERFILE > "${DOCKER_ROOT}/Dockerfile"
|
cat <<DOCKERFILE > "${DOCKER_ROOT}/Dockerfile"
|
||||||
FROM scratch
|
FROM scratch
|
||||||
USER worker
|
USER cubetiq
|
||||||
ADD $(basename $BUILD_TAR) /
|
ADD $(basename $BUILD_TAR) /
|
||||||
CMD ["/bin/sh"]
|
CMD ["/bin/sh"]
|
||||||
DOCKERFILE
|
DOCKERFILE
|
||||||
|
|
||||||
cd $DOCKER_ROOT
|
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 -
|
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
|
ARG BASE_IMAGE
|
||||||
FROM $BASE_IMAGE
|
FROM $BASE_IMAGE
|
||||||
ARG MS_TOKEN
|
ARG MS_TOKEN
|
||||||
RUN wget https://get.aquasec.com/microscanner -O /home/worker/microscanner \
|
RUN wget https://get.aquasec.com/microscanner -O /home/cubetiq/microscanner \
|
||||||
&& echo "8e01415d364a4173c9917832c2e64485d93ac712a18611ed5099b75b6f44e3a5 /home/worker/microscanner" | sha256sum -c - \
|
&& echo "8e01415d364a4173c9917832c2e64485d93ac712a18611ed5099b75b6f44e3a5 /home/cubetiq/microscanner" | sha256sum -c - \
|
||||||
&& chmod +x /home/worker/microscanner \
|
&& chmod +x /home/cubetiq/microscanner \
|
||||||
&& /home/worker/microscanner $MS_TOKEN
|
&& /home/cubetiq/microscanner $MS_TOKEN
|
||||||
DOCKERFILE
|
DOCKERFILE
|
@ -17,4 +17,4 @@ update-ca-certificates
|
|||||||
/sbin/apk upgrade
|
/sbin/apk upgrade
|
||||||
|
|
||||||
# Add a standard user.
|
# Add a standard user.
|
||||||
adduser -D -u1000 worker
|
adduser -D -u1000 cubetiq
|
Loading…
Reference in New Issue
Block a user