Docker
Fast track¶
This will start Connexions with a default configuration, sample petstore
API and contexts.
Data persisted in the connexions
volume.
docker run -it --rm \
-p 2200:2200 \
-v connexions:/app/resources/data \
cubahno/connexions api
Build your own image¶
Build your custom Connexions image with your own data and contexts.
Check directory examples/docker-image-builder
for full working example with files.
FROM cubahno/connexions:v0.1.27
# remove not needed stuff
RUN rm -rf /app/resources/data/services
RUN rm -rf /app/resources/ui
# copy your service definitions, contexts and config
COPY services /app/resources/data/services
COPY contexts /app/resources/data/contexts
COPY callbacks /app/resources/data/callbacks
COPY config.yml /app/resources/data/config.yml
# optimize openapi specs for better performance:
# - removes circular references
# - removes unused properties
# - merges all $refs
RUN simplify-schemas src=/app/resources/data/services replace=true
# done
docker build . -t my-connexions
Run it:
docker run -it --rm \
-p 2200:2200 \
my-connexions api
Login to the container to observe the data and contexts:
docker run -it --rm my-connexions bash
Serve from directory¶
Connexions resources file structure:
resources
└─── data
└───services
└───.openapi
└───service-1
└───index.yml
└───.root
└───get
└───index.json
└───service-2
└───patch
└───users
└───index.json
└───callbacks
└───foo.go
└───bar.go
└───contexts
└───service-1.yml
└───service-2.yml
Directory pattern
For non-openapi
services, the pattern is:
<service-name>/<method>/<path>/<file-name-with-extension>
or
<service-name>/<method>/<path>/index.json
to serve /path
resource.
See File structure for more details.
- Create a directory for your services
- Create a file with a name
index.json
in there and some contents - Run:
docker run -it --rm \
-p 2200:2200 \
-v /path/to/your/data:/app/resources/data \
cubahno/connexions api
- Open
http://localhost:2200
in your browser to see the servedindex.json
contents
The example above didn't map contexts directory
Contexts are essential part to generate meaningful responses.
See Contexts for more details.
Pre-built image with Payment Service Providers¶
Build your custom Connexions image with your own data and contexts.
Check directory examples/docker-image-builder
for full working example with files.
Run it:
docker run -it --rm \
-p 2200:2200 \
cubahno/connexions-psp api
FROM cubahno/connexions:latest
# clean start
RUN rm -rf /app/resources/data/services
RUN rm -rf /app/resources/data/contexts/petstore.yml
# get remote specs and
# optimize them to replace circular references and to improve performance:
# paypal
RUN \
wget -P /app/resources/data/services/.openapi/paypal/ https://raw.githubusercontent.com/paypal/paypal-rest-api-specifications/main/openapi/payments_payment_v2.json && \
wget -P /app/resources/data/services/.openapi/paypal/ https://raw.githubusercontent.com/paypal/paypal-rest-api-specifications/main/openapi/invoicing_v2.json && \
wget -P /app/resources/data/services/.openapi/paypal/ https://raw.githubusercontent.com/paypal/paypal-rest-api-specifications/main/openapi/checkout_orders_v2.json && \
simplify-schemas --src=/app/resources/data/services/.openapi/paypal/ --replace=true
# adyen
RUN \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/AccountService-v6.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/BinLookupService-v54.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/CheckoutService-v70.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/PaymentService-v68.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/RecurringService-v68.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/Webhooks-v1.yaml && \
wget -P /app/resources/data/services/.openapi/adyen/ https://raw.githubusercontent.com/Adyen/adyen-openapi/main/yaml/FundService-v6.yaml && \
simplify-schemas --src=/app/resources/data/services/.openapi/adyen/ --replace=true
# stripe
RUN \
wget -P /app/resources/data/services/.openapi/stripe/ https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml && \
simplify-schemas --src=/app/resources/data/services/.openapi/stripe/ --replace=true --only-required=true
# mobilepay
RUN \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/app_payments_api.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/invoice.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/online.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/pos.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/reporting.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/subscriptions.yaml && \
wget -P /app/resources/data/services/.openapi/mobilepay/ https://raw.githubusercontent.com/MobilePayDev/MobilePayDev.github.io/main/openapi/webhooks.yaml && \
simplify-schemas --src=/app/resources/data/services/.openapi/mobilepay/ --replace=true
# vipps
RUN \
wget -P /app/resources/data/services/.openapi/vipps/ https://raw.githubusercontent.com/vippsas/vipps-recurring-api/master/docs/openapi.yaml && \
simplify-schemas --src=/app/resources/data/services/.openapi/vipps/ --replace=true
# copy your service definitions, contexts and config
COPY services /app/resources/data/services
COPY contexts /app/resources/data/contexts
COPY config.yml /app/resources/data/config.yml
# done