Last active
April 22, 2024 02:42
-
-
Save alombarte/406adb859e9230b7f19a15a5b4b1003a to your computer and use it in GitHub Desktop.
Multi-stage build to compile krakend's flexible configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM devopsfaith/krakend as builder | |
ARG ENV=prod | |
COPY krakend.tmpl . | |
COPY config . | |
# Save temporary file to /tmp to avoid permission errors | |
RUN FC_ENABLE=1 \ | |
FC_OUT=/tmp/krakend.json \ | |
FC_PARTIALS="/etc/krakend/partials" \ | |
FC_SETTINGS="/etc/krakend/settings/$ENV" \ | |
FC_TEMPLATES="/etc/krakend/templates" \ | |
krakend check -d -t -c krakend.tmpl | |
FROM devopsfaith/krakend | |
COPY --from=builder --chown=krakend /tmp/krakend.json . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist uses
krakend check
command with-d
and-t
flags, meaning that after compiling the templates will show the debug of the parsed configuration and will test starting the service. Trying to start the service is safer than just validating that the template compiled, as the file can be perfectly valid but yet have conflicting routes.Example of the assumed file structure:
Build for another environment with:
docker build --build-arg ENV=test -t krakend-test .