-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set broker certificate based on environment
This means an environment variable TLS_SERVER_KEY is required to start the broker docker container. Thus the certificate key is not stored in the image itself and not retrievable if the image is lost. The image may now be published publicly.
- Loading branch information
Showing
5 changed files
with
19 additions
and
28 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
FROM eclipse-mosquitto:latest | ||
|
||
COPY mosquitto/config/ mosquitto/config/ | ||
COPY entrypoint.sh entrypoint.sh | ||
|
||
#ARG TLS_SERVER_KEY | ||
|
||
# RUN start='-----BEGIN PRIVATE KEY-----' && \ | ||
# decoded_key=$(echo $TLS_SERVER_KEY|base64 -d) && \ | ||
# end='-----END PRIVATE KEY-----'&& \ | ||
# echo ${start} > mosquitto/config/certs/server-key.pem && \ | ||
# echo ${decoded_key} >> mosquitto/config/certs/server-key.pem && \ | ||
# echo ${end} >> mosquitto/config/certs/server-key.pem | ||
RUN touch mosquitto/config/certs/server-key.pem | ||
RUN chown -R 1883:1883 mosquitto/config/certs/server-key.pem | ||
|
||
EXPOSE 1883 | ||
|
||
USER 1883 | ||
|
||
CMD ["mosquitto", "-p", "1883", "-c", "mosquitto/config/mosquitto.conf"] | ||
CMD ./entrypoint.sh |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Set certificate key based on environment variable | ||
# TLS_SERVER_KEY | ||
|
||
start='-----BEGIN PRIVATE KEY-----' | ||
end='-----END PRIVATE KEY-----' | ||
|
||
|
||
echo ${start} > mosquitto/config/certs/server-key.pem | ||
echo ${TLS_SERVER_KEY} >> mosquitto/config/certs/server-key.pem | ||
echo ${end} >> mosquitto/config/certs/server-key.pem | ||
|
||
mosquitto -p 1883 -c mosquitto/config/mosquitto.conf |
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