Skip to content

Commit

Permalink
Merge pull request #835 from 200ok-ch/feat/transient-env-vars
Browse files Browse the repository at this point in the history
feat: transient env vars
  • Loading branch information
munen authored Jun 14, 2022
2 parents 0cb5745 + 7561d14 commit 49ef5bf
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ RUN yarn install

COPY . /opt/organice

RUN bin/transient_env_vars.sh bait >> .env

RUN yarn global add serve \
&& yarn build \
&& yarn cache clean \
Expand All @@ -24,9 +26,11 @@ RUN yarn global add serve \
# No root privileges are required. Create and switch to non-root user.
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN addgroup -S organice \
&& adduser -S organice -G organice
&& adduser -S organice -G organice \
&& chown -R organice: .

USER organice

ENV NODE_ENV=production
EXPOSE 5000
ENTRYPOINT ["serve", "-s", "build"]
ENTRYPOINT ["./bin/entrypoint.sh"]
9 changes: 9 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,15 @@ deployed via FTP. The full build script is in

organice is also available as a Docker image.

The docker image recognizes a couple of environment variables. For
example =ORGANICE_WEBDAV_URL= prefills the URL field in the WebDAV
signin form. See [[https://github.com/200ok-ch/organice/blob/master/docker-compose.yaml][docker-compose.yaml]] for an example how to use it.

A full list of such environment variables can be found in [[https://github.com/200ok-ch/organice/blob/master/.env.sample][.env.sample]].

The prefix =REACT_APP_= has to be replaced with =ORGANICE_=. The
naming should be pretty self explanatory.

*** With =docker-compose=

If [[https://docs.docker.com/compose/][docker-compose]] is installed, the following command downloads and
Expand Down
5 changes: 5 additions & 0 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

bin/transient_env_vars.sh switch build serve

serve -p 5000 -s serve
33 changes: 33 additions & 0 deletions bin/transient_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

shopt -s globstar

RVARS=$(cut -d = -f 1 .env.sample)

case $1 in

"bait")
for KEY in $RVARS; do
echo "$KEY=${KEY//REACT_APP_/ORGANICE_}"
done
;;

"switch")
SRC=$2
DST=$3

rm -rf "$DST"
cp -r "$SRC" "$DST"

OVARS=${RVARS//REACT_APP_/ORGANICE_}

for KEY in $OVARS; do
VALUE=${!KEY}
sed -i "s/$KEY/$VALUE/" "$DST"/**/*.js
done
;;

*)
echo "Unknown command: $1"
;;
esac
3 changes: 3 additions & 0 deletions changelog.org
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ When there are updates to the changelog, you will be notified and see a 'gift' i
- Specify default webDAV URL in .env file
- PR: https://github.com/200ok-ch/organice/pull/829
- Thank you [[https://github.com/dmorlitz][dmorlitz]] for the PR🙏
- Docker image recognizes env vars
- PR: https://github.com/200ok-ch/organice/pull/835
- see [[https://organice.200ok.ch/documentation.html#docker][doc]] for more information

* [2022-06-03 Fri]
** Removed
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
- '5000:3000'
logging:
driver: json-file
environment:
ORGANICE_WEBDAV_URL: http://webdav.example.com
apache-webdav:
build:
context: ./
Expand Down

0 comments on commit 49ef5bf

Please sign in to comment.