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 21, 2018
1 parent 9e32302 commit 529d7ad
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ before_install:
script:
- cp -r .env.test .env
- docker-compose build
- docker-compose run -u 1000 --no-deps --rm ico yarn install
- docker-compose up -d
- docker-compose exec ico yarn
- docker-compose exec ico yarn test
- docker-compose exec -u 1000 ico 'yarn test'
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "production"; elif [
"$TRAVIS_BRANCH" == "develop" ]; then echo "stage"; else echo "dev-$(git rev-parse
--short HEAD)" ; fi`
Expand Down
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
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
COPY . .
COPY custom-entrypoint.sh /usr/local/bin/custom-entrypoint.sh

RUN chmod 755 /usr/local/bin/custom-entrypoint.sh && \
addgroup ico && \
adduser -D -H -G ico ico && \
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

USER ico

ENTRYPOINT ["/usr/local/bin/custom-entrypoint.sh"]
CMD ["npm", "start"]
22 changes: 16 additions & 6 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
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/
COPY . .
COPY custom-entrypoint.sh /usr/local/bin/custom-entrypoint.sh

RUN chmod 755 /usr/local/bin/custom-entrypoint.sh && \
addgroup ico && \
adduser -D -H -G ico ico && \
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

USER ico

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

set -eu

for env in $(env); do
key=${env%=*}
[ -n "${key#*_FILE}" ] && continue
val=${env#*=}
key=${key%_FILE}
val=$(cat $val)
export "${key}"="${val}"
done

exec "$@"
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ services:
- 80:3000
- 3000:3000
- 443:4000
volumes:
- ./:/usr/src/app
links:
- auth
- redis
- verify
- rpc
volumes:
- ./:/usr/src/app
depends_on:
- rpc
- mongo
Expand Down

0 comments on commit 529d7ad

Please sign in to comment.