Skip to content

Commit

Permalink
Merge pull request #6 from freezingsaddles/update-requirements-fix-build
Browse files Browse the repository at this point in the history
Update requirements and fix build
  • Loading branch information
obscurerichard authored Jan 8, 2024
2 parents 234715f + e23a1e1 commit 2dcc265
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 66 deletions.
40 changes: 12 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
# BUILD
# =====
FROM ubuntu:22.04 as buildstep
LABEL maintainer="Richard Bullington-McGuire <[email protected]>"

FROM ubuntu:xenial as buildstep
LABEL maintainer="Hans Lellelid <[email protected]>"

COPY resources/docker/sources.list /etc/apt/sources.list
RUN apt-get update

RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:jonathonf/python-3.6
RUN apt-get update

RUN apt-get install -y python3.6 python3.6-dev curl build-essential git
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-dev python3-pip curl build-essential git tzdata

RUN mkdir -p /build/wheels
RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6

RUN pip3 install --upgrade pip setuptools wheel

ADD requirements.txt /tmp/requirements.txt
RUN pip3 wheel -r /tmp/requirements.txt --wheel-dir=/build/wheels

ADD . /app
WORKDIR /app

RUN python3.6 setup.py bdist_wheel -d /build/wheels

RUN python3 setup.py bdist_wheel -d /build/wheels

# DEPLOY
# =====

FROM ubuntu:xenial as deploystep
LABEL maintainer="Hans Lellelid <[email protected]>"

COPY resources/docker/sources.list /etc/apt/sources.list
FROM ubuntu:22.04 as deploystep
LABEL maintainer="Richard Bullington-McGuire <[email protected]>"

RUN apt-get update \
&& apt-get install -y software-properties-common curl \
&& add-apt-repository -y ppa:jonathonf/python-3.6 \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common curl tzdata \
&& apt-get update \
&& apt-get install -y python3.6 vim-tiny --no-install-recommends \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip --no-install-recommends \
&& apt-get clean \
&& curl https://bootstrap.pypa.io/get-pip.py | python3.6 \
&& pip3 install --upgrade pip setuptools wheel \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip setuptools wheel
COPY --from=buildstep /build/wheels /tmp/wheels

RUN pip3 install /tmp/wheels/*

EXPOSE 8000

ENTRYPOINT gunicorn --bind 0.0.0.0:8000 'freezing.nq.app:make_app()'
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ It is designed to run as a container and should be configured with environment v
- `BEANSTALKD_HOST`: The hostname (probably a container link) to a beanstalkd server.
- `BEANSTALKD_PORT`: The port for beanstalkd server (default 11300)
- `STRAVA_VERIFY_TOKEN`: The token to use when verifying the Strava challenge response (must match token used to register subscription).

# Legal

This software is a community-driven effort, and as such the contributions are owned by the individual contributors:

Copyright 2018 Hans Lillelid <br>
Copyright 2020 Richard Bullington-McGuire <br>

This software is licensed under the [Apache 2.0 license](LICENSE).
8 changes: 4 additions & 4 deletions freezing/nq/api/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def on_get(self, req: falcon.Request, resp: falcon.Response):

strava_request = {k: req.get_param(k) for k in ('hub.challenge', 'hub.mode', 'hub.verify_token')}

schema = SubscriptionCallbackSchema(strict=True)
schema = SubscriptionCallbackSchema()
callback: SubscriptionCallback = schema.load(strava_request).data
assert config.STRAVA_VERIFY_TOKEN == callback.hub_verify_token

Expand All @@ -49,8 +49,8 @@ def on_post(self, req: falcon.Request, resp: falcon.Response):
See: http://strava.github.io/api/partner/v3/events/
"""

schema = SubscriptionUpdateSchema(strict=True)
result: SubscriptionUpdate = schema.load(req.media).data
schema = SubscriptionUpdateSchema()
result: SubscriptionUpdate = schema.load(req.media)

# We only care about activities
if result.object_type is not ObjectType.activity:
Expand All @@ -63,7 +63,7 @@ def on_post(self, req: falcon.Request, resp: falcon.Response):
message.operation = result.aspect_type
message.updates = result.updates

json_data = ActivityUpdateSchema().dump(message).data
json_data = ActivityUpdateSchema().dump(message)

log.info("Publishing activity-update: {}".format(message))
self.publisher.publish_message(json_data,
Expand Down
3 changes: 3 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
black==19.10b0
flake8==3.7.9
pur==5.3.0
pytest==3.3.2
pytest-mock==1.6.3
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz
arrow==0.15.5
envparse==0.2.0
falcon==1.3.0
greenstalk==0.5.0
gunicorn==19.7.1
falcon==2.0.0
freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.20.tar.gz
greenstalk==1.0.1
gunicorn==20.0.4
python-mimeparse==1.6.0
six==1.11.0
-e git+https://github.com/freezingsaddles/[email protected]#egg=freezing-model-0.2.2
arrow==0.12.1
six==1.14.0
5 changes: 0 additions & 5 deletions resources/docker/sources.list

This file was deleted.

50 changes: 27 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,42 @@
import re
import warnings

from pip.req import parse_requirements
from setuptools import setup, find_packages
from setuptools import setup

version = '0.1.0'
version = "0.3.6"

long_description = """
freezing-nq is the freezing saddles component for receiving strava webhook events and enquing them for processing.
freezing-nq is the Freezing Saddles component for receiving
strava webhook events and enquing them for processing.
"""

# parse_requirements() returns generator of pip.req.InstallRequirement objects
install_reqs = parse_requirements(os.path.join(os.path.dirname(__file__), 'requirements.txt'), session=False)

# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]
install_reqs = [
"envparse==0.2.0",
"falcon==2.0.0",
"greenstalk==1.0.1",
"gunicorn==20.0.4",
"python-mimeparse==1.6.0",
"six==1.14.0",
"freezing-model",
"arrow==0.15.5",
]

setup(
name='freezing-nq',
name="freezing-nq",
version=version,
author='Hans Lellelid',
author_email='[email protected]',
url='http://github.com/freezingsaddles/freezing-nq',
license='Apache',
description='Freezing Saddles activity receive and enqueue worker',
author="Hans Lellelid",
author_email="[email protected]",
url="http://github.com/freezingsaddles/freezing-nq",
license="Apache",
description="Freezing Saddles activity receive and enqueue worker",
long_description=long_description,
packages=['freezing.nq', 'freezing.nq.api'],
install_requires=reqs,
packages=["freezing.nq", "freezing.nq.api"],
install_requires=install_reqs,
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
],
zip_safe=True
zip_safe=True,
)

0 comments on commit 2dcc265

Please sign in to comment.