commit 4a987fb30e0622d2e007617b2d0d29314239d9c2 Author: Sambo Chea Date: Wed Jul 14 14:43:18 2021 +0700 Task: Add docker container inside alpine linux for docker image and github workflows diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..fc361fc --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,27 @@ +name: Docker CI + +on: + push: + branches: [ main ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_SECRET }} + - + name: Checkout + uses: actions/checkout@v2 + + - + name: Build and Push from Makefile + run: | + make build \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af6b56a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.dccache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..935460a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM cubetiq/calpine-os-linux:latest +LABEL maintainer="sombochea@cubetiqs.com" + +RUN apk add --no-cache \ + ca-certificates \ + openssh-client + +RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf + +ENV DOCKER_VERSION 20.10.7 + +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz'; \ + ;; \ + 'armhf') \ + url='https://download.docker.com/linux/static/stable/armel/docker-${DOCKER_VERSION}.tgz'; \ + ;; \ + 'armv7') \ + url='https://download.docker.com/linux/static/stable/armhf/docker-${DOCKER_VERSION}.tgz'; \ + ;; \ + 'aarch64') \ + url='https://download.docker.com/linux/static/stable/aarch64/docker-${DOCKER_VERSION}.tgz'; \ + ;; \ + *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;; \ + esac; \ + \ + wget -O docker.tgz "$url"; \ + \ + tar --extract \ + --file docker.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + ; \ + rm docker.tgz; \ + \ + dockerd --version; \ + docker --version + +COPY modprobe.sh /usr/local/bin/modprobe +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh +RUN chmod +x /usr/local/bin/modprobe + +ENV DOCKER_TLS_CERTDIR=/certs +RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["sh"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4e8c5f9 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +DOCKER_IMAGE=cubetiq/calpine-docker +DOCKER_IMAGE_NAME=${DOCKER_IMAGE}:20.10.7 + +build: + @echo 'Starting docker build' + docker build . -t ${DOCKER_IMAGE} + + @echo 'Starting docker push' + docker tag ${DOCKER_IMAGE} ${DOCKER_IMAGE_NAME} + docker push ${DOCKER_IMAGE} + docker push ${DOCKER_IMAGE_NAME} + +.PHONY:build \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..02f9c9c --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# CUBETIQ Alpine OS Linux with Docker 20.10.7 +![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/cubetiq/calpine-docker) +![Docker Pulls](https://img.shields.io/docker/pulls/cubetiq/calpine-docker) + +- CUBETIQ Alpine OS Linux (3.13.3) +- Docker (20.10.7) + +# [Docker Hub](https://hub.docker.com/r/cubetiq/calpine-docker) +```shell +docker push cubetiq/calpine-docker +``` + +# Usage +```shell +docker run --rm -it cubetiq/calpine-docker /bin/sh +``` + +# Example +```Dockerfile +FROM cubetiq/calpine-docker:latest +LABEL maintainer="sombochea@cubetiqs.com" + +RUN docker version + +CMD [ "sh" ] +``` + +# Reference +- Docker: [GitHub](https://github.com/docker-library/docker/tree/279ba9c93e8e26a15171645bd511ea8476c4706e/20.10) + +# Contributors +- Sambo Chea + +# License +```text +MIT License + +Copyright (c) 2018-2020 Dave Hall + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECT +``` \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..e69de29 diff --git a/modprobe.sh b/modprobe.sh new file mode 100644 index 0000000..ea037ba --- /dev/null +++ b/modprobe.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu + +for module; do + if [ "${module#-}" = "$module" ]; then + ip link show "$module" || true + lsmod | grep "$module" || true + fi +done + +export PATH='/usr/sbin:/usr/bin:/sbin:/bin' +exec modprobe "$@" \ No newline at end of file