Skip to content

Commit 8b6fcdf

Browse files
jason-foxaarranz
authored andcommitted
Fix #32 - Add Docker Secrets support (#33)
* Add Docker Secrets support
1 parent 374df5d commit 8b6fcdf

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
# What is WireCloud?
1212

13+
[![](https://nexus.lab.fiware.org/repository/raw/public/badges/chapters/visualization.svg)](https://www.fiware.org/developers/catalogue/)
14+
[![Support badge](https://img.shields.io/badge/tag-fiware--wirecloud-orange.svg?logo=stackoverflow)](https://stackoverflow.com/questions/tagged/fiware-wirecloud)
15+
1316
WireCloud builds on cutting-edge end-user development, RIA and semantic technologies to offer a next-generation end-user centred web application mashup platform aimed at leveraging the long tail of the Internet of Services. WireCloud builds on cutting-edge end-user (software) development, RIA and semantic technologies to offer a next-generation end-user centred web application mashup platform aimed at allowing end users without programming skills to easily create web applications and dashboards/cockpits (e.g. to visualize their data of interest or to control their domotized home or environment). Web application mashups integrate heterogeneous data, application logic, and UI components (widgets) sourced from the Web to create new coherent and value-adding composite applications. They are targeted at leveraging the "long tail" of the Web of Services (a.k.a. the Programmable Web) by exploiting rapid development, DIY, and shareability. They typically serve a specific situational (i.e. immediate, short-lived, customized) need, frequently with high potential for reuse. Is this "situational" character which precludes them to be offered as 'off-the-shelf' functionality by solution providers, and therefore creates the need for a tool like WireCloud
1417

15-
WireCloud is part of [FIWARE](https://www.fiware.org/). Check it out in the [Catalogue](https://catalogue.fiware.org/enablers/application-mashup-wirecloud)
18+
WireCloud is part of [FIWARE](https://www.fiware.org/). Check it out in the [Catalogue](https://www.fiware.org/developers/catalogue/)
1619

1720
[![WireCloud's logo](https://raw.githubusercontent.com/Wirecloud/docker-wirecloud/master/logo.png)](https://github.com/Wirecloud/wirecloud)
1821

@@ -58,6 +61,25 @@ appropriately.
5861
[ALLOWED_HOSTS]: https://docs.djangoproject.com/en/2.1/ref/settings/#allowed-hosts
5962

6063

64+
### Docker Secrets
65+
66+
As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to some sensitive
67+
environment variables, causing the initialization script to load the values for those variables from files present in
68+
the container. In particular, this can be used to load passwords from Docker secrets stored in
69+
`/run/secrets/<secret_name>` files. For example:
70+
71+
```console
72+
docker run --name wirecloud -e DB_PASSWORD_FILE=/run/secrets/password -d fiware/wirecloud
73+
```
74+
75+
Currently, this `_FILE` suffix is supported for:
76+
77+
- `DB_PASSWORD`
78+
- `DB_USERNAME`
79+
- `SOCIAL_AUTH_FIWARE_KEY`
80+
- `SOCIAL_AUTH_FIWARE_SECRET`
81+
82+
6183
## Running manage.py commands
6284

6385
You can run any available `manage.py` command by using `docker exec -ti some-wirecloud manage.py ...`. For example, you can create superusers/administrators by running the following command:
@@ -205,6 +227,7 @@ http {
205227
Run `docker stack deploy -c docker-compose.yml wirecloud` (or `docker-compose -f docker-compose.yml up`), wait for it to initialize completely, and visit `http://swarm-ip`, `http://localhost`, or `http://host-ip` (as appropriate). Also, take into account that you should configure https to have a production-ready deployment of WireCloud (not covered by this example).
206228

207229

230+
208231
## Customizations
209232

210233
If you want to customize your WireCloud installation, the best option is to create a new docker image by extending one of the official images and installing new modules. For example, you can follow the following [tutorial](https://wirecloud.readthedocs.io/en/stable/development/platform/themes/) for creating a custom theme and install it on the extended image and use the `DEFAULT_THEME` environment variable to configure it as the default theme.
@@ -327,7 +350,6 @@ $ docker-compose up -d
327350

328351
This docker-compose configuration will detect when the WireCloud configuration is missing and, in that case, it will populate the volume at `/opt/wirecloud_instance` (mapped to the local `wirecloud_instance` folder), the database and the `/var/www/static` volume (mapped to the local `static` folder). This initial configuration will not include any administrator user so, please create one using the `createsuperuser` command.
329352

330-
331353
# License
332354

333355
View license information for [WireCloud](https://github.com/Wirecloud/wirecloud/blob/develop/LICENSE.txt).

dev/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ RUN adduser --system --group --shell /bin/bash wirecloud && \
4646
cd /opt && \
4747
wirecloud-admin startproject wirecloud_instance wirecloud_instance && \
4848
chown -R wirecloud:wirecloud wirecloud_instance /var/www/static && \
49-
chmod a+x wirecloud_instance/manage.py
49+
chmod a+x wirecloud_instance/manage.py && \
50+
chmod a+x /docker-entrypoint.sh
5051

5152
COPY ./settings.py ./urls.py /opt/wirecloud_instance/wirecloud_instance/
5253

dev/docker-entrypoint.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
set -e
44

5+
# usage: file_env VAR [DEFAULT]
6+
# ie: file_env 'DB_PASSWORD' 'example'
7+
# (will allow for "$DB_PASSWORD_FILE" to fill in the value of
8+
# "$DB_PASSWORD" from a file, especially for Docker's secrets feature)
9+
file_env() {
10+
local var="$1"
11+
local fileVar="${var}_FILE"
12+
local def="${2:-}"
13+
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
14+
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
15+
exit 1
16+
fi
17+
local val="$def"
18+
if [ "${!var:-}" ]; then
19+
val="${!var}"
20+
elif [ "${!fileVar:-}" ]; then
21+
val="$(< "${!fileVar}")"
22+
fi
23+
export "$var"="$val"
24+
unset "$fileVar"
25+
}
26+
27+
file_env 'DB_PASSWORD' 'postgres'
28+
file_env 'DB_USERNAME' 'postgres'
29+
file_env 'SOCIAL_AUTH_FIWARE_KEY'
30+
file_env 'SOCIAL_AUTH_FIWARE_SECRET'
31+
532
# allow the container to be started with `--user`
633
if [ "$(id -u)" = '0' ]; then
734
chown -R wirecloud data

0 commit comments

Comments
 (0)