Adds a sample docker-compose setup that uses the new docker image.
This commit is contained in:
parent
6e076dff8a
commit
ab60d9413f
|
@ -46,8 +46,7 @@ ARG FDB_ADDITIONAL_VERSIONS="5.1.7"
|
|||
RUN mkdir -p scripts
|
||||
COPY download_multiversion_libraries.bash scripts
|
||||
|
||||
RUN mkdir -p /usr/lib/fdb
|
||||
ADD $FDB_WEBSITE/downloads/$FDB_VERSION/linux/libfdb_c_$FDB_VERSION.so /usr/lib/fdb
|
||||
ADD $FDB_WEBSITE/downloads/$FDB_VERSION/linux/libfdb_c_$FDB_VERSION.so /usr/lib/libfdb_c.so
|
||||
RUN bash scripts/download_multiversion_libraries.bash $FDB_WEBSITE $FDB_ADDITIONAL_VERSIONS
|
||||
|
||||
# Set Up Runtime Scripts and Directoris
|
||||
|
|
|
@ -63,7 +63,7 @@ You can also use this image to provide files for images that are clients of a
|
|||
FoundationDB cluster, by using the `from` argument of the `COPY` command. Some
|
||||
files you may want to copy are:
|
||||
|
||||
* `/usr/lib/fdb/libfdb_*.so`: The primary FoundationDB client library
|
||||
* `/usr/lib/libfdb_c.so`: The primary FoundationDB client library
|
||||
* `/usr/lib/fdb/multiversion/libfdb_*.so`: Additional versions of the client
|
||||
library, which you can use if you are setting up a multiversion client.
|
||||
* `/var/fdb/scripts/create_cluster_file.bash`: A script for setting up the
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
COMPOSE_PROJECT_NAME=fdbpythonsample
|
|
@ -0,0 +1,22 @@
|
|||
FROM python:3.6
|
||||
|
||||
RUN apt-get update; apt-get install -y dnsutils
|
||||
|
||||
RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=foundationdb:5.2.5 /usr/lib/libfdb_c.so /usr/lib
|
||||
COPY --from=foundationdb:5.2.5 /usr/bin/fdbcli /usr/bin/
|
||||
COPY --from=foundationdb:5.2.5 /var/fdb/scripts/create_cluster_file.bash /app
|
||||
|
||||
COPY requirements.txt /app
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY start.bash /app
|
||||
COPY server.py /app
|
||||
RUN chmod u+x /app/start.bash
|
||||
|
||||
CMD /app/start.bash
|
||||
|
||||
ENV FLASK_APP=server.py
|
||||
ENV FLASK_ENV=development
|
|
@ -0,0 +1,2 @@
|
|||
Flask==1.0.2
|
||||
foundationdb==5.1.5
|
|
@ -0,0 +1,25 @@
|
|||
from flask import Flask
|
||||
import fdb
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
fdb.api_version(510)
|
||||
db=fdb.open()
|
||||
|
||||
COUNTER_KEY=fdb.tuple.pack(('counter',))
|
||||
def _increment_counter(tr):
|
||||
counter_value = tr[COUNTER_KEY]
|
||||
if counter_value == None:
|
||||
counter = 1
|
||||
else:
|
||||
counter = fdb.tuple.unpack(counter_value)[0] + 1
|
||||
tr[COUNTER_KEY] = fdb.tuple.pack((counter,))
|
||||
return counter
|
||||
|
||||
@app.route("/counter", methods=['GET'])
|
||||
def get_counter():
|
||||
return str(fdb.tuple.unpack(db[COUNTER_KEY])[0])
|
||||
|
||||
@app.route("/counter/increment", methods=['POST'])
|
||||
def increment_counter():
|
||||
return str(_increment_counter(db))
|
|
@ -0,0 +1,4 @@
|
|||
#! /bin/bash
|
||||
|
||||
/app/create_cluster_file.bash
|
||||
FLASK_APP=server.py flask run --host=0.0.0.0
|
|
@ -0,0 +1,13 @@
|
|||
version: '3'
|
||||
services:
|
||||
fdb:
|
||||
image: foundationdb:5.2.5
|
||||
environment:
|
||||
FDB_COORDINATOR: fdbpythonsample_fdb_1
|
||||
app:
|
||||
build:
|
||||
context: app
|
||||
ports:
|
||||
- 5000:5000
|
||||
environment:
|
||||
FDB_COORDINATOR: fdbpythonsample_fdb_1
|
Loading…
Reference in New Issue