Skip to content

Commit e902d0c

Browse files
author
albertovara
committed
Added example
1 parent 4b2c061 commit e902d0c

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM python:3.6.4-alpine3.7
2+
3+
RUN apk add --update curl gcc g++ git libffi-dev openssl-dev python3-dev build-base linux-headers \
4+
&& rm -rf /var/cache/apk/*
5+
6+
ENV PYTHONUNBUFFERED=1 APP_HOME=/microservice/
7+
ENV CONFIGMAP_FILE="$APP_HOME"config-docker.yml
8+
9+
RUN mkdir $APP_HOME && adduser -S -D -H python
10+
RUN chown -R python $APP_HOME
11+
WORKDIR $APP_HOME
12+
13+
ADD requirement*.txt $APP_HOME
14+
RUN pip install --upgrade pip
15+
RUN pip install -r requirements.txt
16+
17+
ADD . $APP_HOME
18+
19+
EXPOSE 5000
20+
USER python
21+
22+
CMD ["gunicorn", "--worker-class", "gevent", "--workers", "8", "--log-level", "INFO", "--bind", "0.0.0.0:5000", "manage:app"]

examples/mininum_microservice_docker/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
my-minimal-microservice:
2+
APP_NAME: "Python Microservice"
3+
environment: "I'm running in docker"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
my-minimal-microservice:
2+
APP_NAME: "Python Microservice"
3+
environment: "I'm running in a local machine"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
from flask import jsonify
3+
from pyms.flask.app import Microservice
4+
5+
ms = Microservice(service="my-minimal-microservice", path=__file__)
6+
app = ms.create_app()
7+
8+
@app.route("/")
9+
def example():
10+
return jsonify({"main": ms.config.environment})
11+
12+
if __name__ == '__main__':
13+
app.run()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
py-ms==1.0.0
2+
gunicorn
3+
gevent

0 commit comments

Comments
 (0)