Skip to content

Commit 517ba4b

Browse files
authored
Drop building cryptography from source (#219)
1 parent 930e844 commit 517ba4b

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,40 @@ on:
88

99
jobs:
1010
buildx:
11+
name: Build Docker Image
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout
1415
uses: actions/checkout@v4
1516

17+
- name: Check pushing to Docker Hub
18+
id: push-other-places
19+
# Only push to Dockerhub from the main repo
20+
# Otherwise forks would require a Docker Hub account and secrets setup
21+
run: |
22+
if [[ ${{ github.repository_owner }} == "caronc" ]] ; then
23+
echo "Enabling DockerHub image push"
24+
echo "enable=true" >> $GITHUB_OUTPUT
25+
else
26+
echo "Not pushing to DockerHub"
27+
echo "enable=false" >> $GITHUB_OUTPUT
28+
fi
29+
30+
# Mostly for forks, set an output package name for ghcr.io using the repo name
31+
- name: Set ghcr repository name
32+
id: set-ghcr-repository
33+
run: |
34+
ghcr_name=$(echo "${{ github.repository_owner }}/apprise" | awk '{ print tolower($0) }')
35+
echo "Name is ${ghcr_name}"
36+
echo "ghcr-repository=${ghcr_name}" >> $GITHUB_OUTPUT
37+
1638
- name: Docker meta
1739
id: docker_meta
1840
uses: docker/metadata-action@v5
1941
with:
2042
images: |
21-
docker.io/caronc/apprise
43+
ghcr.io/${{ steps.set-ghcr-repository.outputs.ghcr-repository }}
44+
name=docker.io/caronc/apprise,enable=${{ steps.push-other-places.outputs.enable }}
2245
tags: |
2346
type=semver,event=tag,pattern={{version}}
2447
type=semver,event=tag,pattern={{major}}.{{minor}}
@@ -30,19 +53,6 @@ jobs:
3053
- name: Set up Docker Buildx
3154
uses: docker/setup-buildx-action@v3
3255

33-
- name: Check pushing to Docker Hub
34-
id: push-other-places
35-
# Only push to Dockerhub from the main repo
36-
# Otherwise forks would require a Docker Hub account and secrets setup
37-
run: |
38-
if [[ ${{ github.repository_owner }} == "caronc" ]] ; then
39-
echo "Enabling DockerHub image push"
40-
echo "enable=true" >> $GITHUB_OUTPUT
41-
else
42-
echo "Not pushing to DockerHub"
43-
echo "enable=false" >> $GITHUB_OUTPUT
44-
fi
45-
4656
- name: Login to DockerHub
4757
uses: docker/login-action@v3
4858
# Don't attempt to login is not pushing to Docker Hub
@@ -51,6 +61,13 @@ jobs:
5161
username: ${{ secrets.DOCKER_USERNAME }}
5262
password: ${{ secrets.DOCKER_PASSWORD }}
5363

64+
- name: Login to GitHub Container Registry
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ghcr.io
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
5471
- name: Build and push
5572
uses: docker/build-push-action@v6
5673
with:

Dockerfile

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,22 @@ ENV APPRISE_CONFIG_DIR=/config
1313
ENV APPRISE_ATTACH_DIR=/attach
1414
ENV APPRISE_PLUGIN_PATHS=/plugin
1515

16-
FROM base AS builder
17-
18-
WORKDIR /build/
19-
20-
# Install nginx, supervisord, and cryptography dependencies
21-
RUN set -eux && \
22-
echo "Installing build dependencies" && \
23-
apt-get update -qq && \
24-
apt-get install -y -qq \
25-
curl \
26-
build-essential \
27-
libffi-dev \
28-
libssl-dev \
29-
pkg-config && \
30-
echo "Updating pip and getting requirements to build" && \
31-
# Cryptography documents that the latest version of pip3 must always be used
32-
python3 -m pip install --upgrade \
33-
pip \
34-
wheel && \
35-
echo "Installing latest rustc" && \
36-
# Pull in bleeding edge of rust to keep up with cryptography build requirements
37-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \
38-
. "$HOME/.cargo/env" && \
39-
echo "Buildingcryptography" && \
40-
python3 -m pip wheel \
41-
--no-binary cryptography \
42-
cryptography
43-
4416
FROM base AS runtime
4517

4618
# Install requirements and gunicorn
4719
COPY ./requirements.txt /etc/requirements.txt
48-
COPY --from=builder /build/*.whl ./
20+
4921
RUN set -eux && \
5022
echo "Installing nginx" && \
5123
apt-get update -qq && \
5224
apt-get install -y -qq \
5325
nginx && \
54-
echo "Installing cryptography" && \
55-
pip3 install *.whl && \
5626
echo "Installing tools" && \
5727
apt-get install -y -qq \
5828
curl sed git && \
5929
echo "Installing python requirements" && \
6030
pip3 install --no-cache-dir -q -r /etc/requirements.txt gunicorn supervisor && \
31+
pip freeze && \
6132
echo "Cleaning up" && \
6233
apt-get --yes autoremove --purge && \
6334
apt-get clean --yes && \

0 commit comments

Comments
 (0)