From 86da76ba96be640d79ca2fcbec88d2eb5ea63baf Mon Sep 17 00:00:00 2001 From: Cyb3r Jak3 Date: Sun, 23 May 2021 20:33:33 -0700 Subject: [PATCH] Add Alpine images (#5) * Adding alpine build * Fixed quotes * Using flavor for the tags * Split action for quicker build * Removing branch tag * Updating documentation --- .github/workflows/docker.yml | 86 ++++++++++++++++++++++++++++++++---- Dockerfile | 4 -- Readme.md | 8 ++++ alpine.Dockerfile | 10 +++++ requirements.txt | 4 +- 5 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 alpine.Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9ceb688..335182d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,12 +5,11 @@ on: jobs: - Docker: + Slim: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 - name: Login to Docker @@ -33,18 +32,19 @@ jobs: username: ${{ secrets.GITLAB_USER }} password: ${{ secrets.GITLAB_TOKEN }} - - - name: Docker meta + - name: Docker Meta id: meta uses: docker/metadata-action@v3 with: images: cyb3rjak3/pypy-flask,ghcr.io/cyb3r-jak3/pypy-flask,registry.gitlab.com/cyb3r-jak3/pypy-flask tags: | - type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=sha + labels: | + org.label-schema.vcs-url=https://github.com/Cyb3r-Jak3/pypy-flask.git + org.label-schema.schema-version=1.0.0-rc1 - name: Set up QEMU uses: docker/setup-qemu-action@v1.1.0 @@ -56,10 +56,10 @@ jobs: uses: actions/cache@v2.1.5 with: path: /tmp/.buildx-cache - key: buildx-${{ github.sha }} - restore-keys: buildx + key: buildx-slim-${{ github.sha }} + restore-keys: buildx-slim - - name: Build and Push + - name: Slim Build and Push uses: docker/build-push-action@v2.4.0 with: platforms: linux/amd64,linux/arm64 @@ -68,3 +68,71 @@ jobs: push: ${{ startsWith(github.ref, 'refs/tags/v') }} file: Dockerfile tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + Alpine: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to Docker + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login To GitHub + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Login To GitLab + uses: docker/login-action@v1 + with: + registry: registry.gitlab.com + username: ${{ secrets.GITLAB_USER }} + password: ${{ secrets.GITLAB_TOKEN }} + + - name: Docker Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: cyb3rjak3/pypy-flask,ghcr.io/cyb3r-jak3/pypy-flask,registry.gitlab.com/cyb3r-jak3/pypy-flask + flavor: | + suffix=-alpine + tags: | + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + labels: | + org.label-schema.vcs-url=https://github.com/Cyb3r-Jak3/pypy-flask.git + org.label-schema.schema-version=1.0.0-rc1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1.1.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.3.0 + + - name: Cache Docker layers + uses: actions/cache@v2.1.5 + with: + path: /tmp/.buildx-cache + key: buildx-alpine-${{ github.sha }} + restore-keys: buildx-alpine + + - name: Alpine Build and Push + uses: docker/build-push-action@v2.4.0 + with: + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + push: ${{ startsWith(github.ref, 'refs/tags/v') }} + file: alpine.Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6d0dcd7..37ae494 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ FROM pypy:3-slim -LABEL org.label-schema.vcs-url="https://github.com/Cyb3r-Jak3/pypy-flask.git" \ - org.label-schema.schema-version="1.0.0-rc1" \ - org.opencontainers.image.source="https://github.com/Cyb3r-Jak3/pypy-flask" - COPY requirements.txt /tmp/pip-tmp/ RUN apt-get update \ && apt install --no-install-recommends -y build-essential \ diff --git a/Readme.md b/Readme.md index c231359..26c3c13 100644 --- a/Readme.md +++ b/Readme.md @@ -24,3 +24,11 @@ You can replace the FROM image with any of the following: - ghcr.io/cyb3r-jak3/pypy-flask:latest - cyb3rjak3/pypy-flask:latest - registry.gitlab.com/cyb3r-jak3/pypy-flask:latest + +### Alpine + +There are also alpine based images avaiable. All alpine images end with `-alpine` + +- ghcr.io/cyb3r-jak3/pypy-flask:latest-alpine +- cyb3rjak3/pypy-flask:latest-alpine +- registry.gitlab.com/cyb3r-jak3/pypy-flask:latest-alpine \ No newline at end of file diff --git a/alpine.Dockerfile b/alpine.Dockerfile new file mode 100644 index 0000000..71e724c --- /dev/null +++ b/alpine.Dockerfile @@ -0,0 +1,10 @@ +FROM jamiehewland/alpine-pypy:alpine3.11 + + +RUN apk add --no-cache libffi-dev gcc musl-dev make build-base + +COPY requirements.txt /tmp/pip-tmp/ +RUN pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ + && rm -rf /tmp/pip-tmp + +RUN apk del libffi-dev gcc musl-dev make build-base \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3f6d746..0d7e630 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ Flask==2.0.1 -gevent==21.1.2 -gunicorn==20.1.0 \ No newline at end of file +gunicorn==20.1.0 +gevent==21.1.2 \ No newline at end of file