diff --git a/docker/docker-compose.json-registration.yml b/docker/docker-compose.json-registration.yml new file mode 100644 index 0000000000..9cd4030faf --- /dev/null +++ b/docker/docker-compose.json-registration.yml @@ -0,0 +1,15 @@ +version: '3.8' + +name: json-registration + +services: + flask_app: + build: ./json-registration + ports: + - "80:80" + volumes: + - ./json-registration/:/app/ + +networks: + open-forms-dev: + name: open-forms-dev diff --git a/docker/json-registration/Dockerfile b/docker/json-registration/Dockerfile new file mode 100644 index 0000000000..56d713f353 --- /dev/null +++ b/docker/json-registration/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Python image from the Docker Hub +FROM python:3.12-slim + +# Set the working directory +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install the dependencies +RUN pip install Flask + +# Make port 80 available to the world outside this container +EXPOSE 80 + +# Run app.py when the container launches +CMD ["python", "app.py"] diff --git a/docker/json-registration/README.md b/docker/json-registration/README.md new file mode 100644 index 0000000000..ca3a895fb9 --- /dev/null +++ b/docker/json-registration/README.md @@ -0,0 +1,18 @@ +# JSON registration plugin + +The `docker-compose.json-registration.yml` compose file is available to run a mock service intended +to simulate a receiving server to test the JSON registration backend plugin. It contains an endpoint for +sending json data (`json_plugin`) and testing the connection (`test_connection`). + +The `json_plugin` endpoint returns a confirmation message that the data was received, together with the +received data. The `test_connection` endpoint just returns an 'OK' message. + +## docker compose + +Start an instance in your local environment from the project root: + +```bash +docker compose -f docker/docker-compose.json-registration.yml up -d +``` + +This starts a flask application at http://localhost:80/ with the endpoints `json_plugin` and `test_connection`. diff --git a/docker/json-registration/app.py b/docker/json-registration/app.py new file mode 100644 index 0000000000..e2e8b08bcb --- /dev/null +++ b/docker/json-registration/app.py @@ -0,0 +1,20 @@ +from flask import Flask, jsonify, request + + +app = Flask(__name__) + +@app.route("/json_plugin", methods=["POST"]) +def json_plugin_post(): + data = request.get_json() + + message = "No data" if data is None else "Data received" + return jsonify({"message": message, "data": data}), 201 + + +@app.route("/test_connection", methods=["GET"]) +def test_connection(): + return jsonify({"message": "OK"}), 200 + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=80, debug=True)