Skip to content

Commit

Permalink
Merge pull request #14 from gpailler/master
Browse files Browse the repository at this point in the history
  • Loading branch information
pajikos authored Feb 18, 2021
2 parents f0ba93b + 40aa6ab commit bb2b452
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
.github
README.MD
LICENSE
52 changes: 52 additions & 0 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker image

on:
workflow_dispatch:
inputs:
docker_tag:
description: 'Docker image tag'
required: true
default: 'latest'

env:
PLATFORMS: linux/amd64,linux/arm/v6,linux/arm64
DOCKER_HUB_REPOSITORY: ${{ github.repository }}
DOCKER_HUB_TAG: ${{ github.event.inputs.docker_tag }}

jobs:
docker:
name: Docker build and push
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU for multi-arch build
uses: docker/setup-qemu-action@v1

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ env.DOCKER_HUB_REPOSITORY }}:${{ env.DOCKER_HUB_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
35 changes: 18 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
FROM python:3-alpine
FROM python:3-alpine AS base

RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/community' >> /etc/apk/repositories
RUN apk update
RUN apk add --no-cache pkgconfig gammu=1.39.0-r2 gammu-libs=1.39.0-r2 gammu-dev=1.39.0-r2
RUN mkdir ssl
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/community' >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache pkgconfig gammu=1.39.0-r2 gammu-libs=1.39.0-r2 gammu-dev=1.39.0-r2

ENV BASE_PATH /sms-gw
RUN mkdir $BASE_PATH
WORKDIR $BASE_PATH
ADD requirements.txt .
ADD gammu.config .
ADD credentials.txt .
ADD support.py .
RUN python -m pip install -U pip

#RUN pip install -r requirements.txt
# Build dependencies in a dedicated stage
FROM base AS dependencies
COPY requirements.txt .
RUN apk add --no-cache --virtual .build-deps libffi-dev openssl-dev gcc musl-dev python3-dev cargo \
&& pip install -r requirements.txt

RUN apk add --no-cache --virtual .build-deps libffi-dev openssl-dev gcc musl-dev \
&& pip install -r requirements.txt \
&& apk del .build-deps libffi-dev openssl-dev gcc musl-dev
# Switch back to base layer for final stage
FROM base AS final
ENV BASE_PATH /sms-gw
RUN mkdir $BASE_PATH /ssl
WORKDIR $BASE_PATH
COPY . $BASE_PATH

ADD run.py .
COPY --from=dependencies /root/.cache /root/.cache
RUN pip install -r requirements.txt && rm -rf /root/.cache

CMD [ "python", "./run.py" ]

0 comments on commit bb2b452

Please sign in to comment.