Skip to content

Commit

Permalink
Add ability for image to read env from a file by _FILE suffix #175
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekNS committed Jun 15, 2018
1 parent 9e32302 commit d01ff95
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
FROM mhart/alpine-node:8.9.1

RUN apk update && apk upgrade && apk add git && apk add python && apk add make && apk add g++ && npm i -g yarn
WORKDIR /usr/src/app
ADD . .
ADD custom-entrypoint.sh /usr/local/bin/custom-entrypoint.sh

RUN chmod 755 /usr/local/bin/custom-entrypoint.sh && apk add --update --no-cache git python make g++ && \
npm i -g yarn && \
yarn install

VOLUME /usr/src/app
EXPOSE 3000
EXPOSE 4000
WORKDIR /usr/src/app


ENTRYPOINT ["/usr/local/bin/custom-entrypoint.sh"]
CMD ["npm", "start"]
16 changes: 10 additions & 6 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM mhart/alpine-node:8.6

RUN mkdir -p /usr/src/app
ADD . /usr/src/app

WORKDIR /usr/src/app

RUN mkdir -p /usr/src/app/dist
RUN cp -r src/certs dist/
ADD . .
ADD custom-entrypoint.sh /usr/local/bin/custom-entrypoint.sh

RUN chmod 755 /usr/local/bin/custom-entrypoint.sh && mkdir -p /usr/src/app/dist && cp -r src/certs dist/
RUN apk add --update --no-cache git python make g++ && \
npm i -g yarn && \
yarn install && \
yarn run build && \
yarn install --prod && \
apk del --purge git python make g++ && \
rm -rf ./src

CMD npm run serve
EXPOSE 3000
EXPOSE 4000

ENTRYPOINT ["/usr/local/bin/custom-entrypoint.sh"]
CMD ["npm", "run", "serve"]
12 changes: 12 additions & 0 deletions custom-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

for env in $(env); do
echo $env | grep '_FILE=' || continue
key=${env%=*}
val=${env#*=}
key=${key%_FILE}
val=$(cat $val)
export "${key}"="${val}"
done

exec "$@"

0 comments on commit d01ff95

Please sign in to comment.