Skip to content

Commit

Permalink
Squashed 'services/auth/' changes from 5cd7788..1c7de1a
Browse files Browse the repository at this point in the history
1c7de1a Merge pull request attlas#23 from VladyslavKurmaz/master
ea8ebbc Docker support
7d1fe6d Docker support

git-subtree-dir: services/auth
git-subtree-split: 1c7de1a7879c3a1384dd70d63027d0613bbddcf5
  • Loading branch information
VladyslavKurmaz committed Aug 20, 2018
1 parent e3691fd commit e6ac8e2
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 45 deletions.
35 changes: 19 additions & 16 deletions .env.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash -e

# can be used for standalon project
#:'
export $(cat ./.env | grep -v ^# | xargs)
#'
if [ -f './../../.env' ]; then
echo '## Export variables from project .env file'
export $(cat ./../../.env | grep -v ^# | xargs)
export COMPONENT_ID="${ID}"
export COMPONENT_VERSION=${PROJECT_VERSION}
export COMPONENT_PARAM_HOST=${HOST}
export COMPONENT_PARAM_LSTN=${LSTN}
export COMPONENT_PARAM_PORT=${PORT}
export COMPONENT_PARAM_PORTS=${PORTS}
export COMPONENT_PARAM_SECRET=${SECRET}
# export configuration from the top level of microservice
: '
export $(cat ./../../.env | grep -v ^# | xargs)
export COMPONENT_ID="${ID}"
export COMPONENT_VERSION=${PROJECT_VERSION}
export COMPONENT_PARAM_HOST=${HOST}
export COMPONENT_PARAM_LSTN=${LSTN}
export COMPONENT_PARAM_PORT=${PORT}
export COMPONENT_PARAM_PORTS=${PORTS}
export COMPONENT_PARAM_SECRET=${SECRET}
'
printenv | grep COMPONENT_
# project specific mappings
fi
if [ -f './.env' ]; then
echo '## Export variables from local .env file'
export $(cat ./.env | grep -v ^# | xargs)
fi
printenv | grep COMPONENT_ | sort
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ COMPONENT_PARAM_PORT=${COMPONENT_PARAM_PORT}
COMPONENT_PARAM_PORTS=${COMPONENT_PARAM_PORTS}
COMPONENT_PARAM_SECRET=${COMPONENT_PARAM_SECRET}
COMPONENT_PARAM_CORS_WHITELIST=${COMPONENT_PARAM_CORS_WHITELIST}

## project specific parameters
63 changes: 63 additions & 0 deletions .tln.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"stages":{
"prereq":{
"shell":[
"envsubst < .env.template > .env",
"envsubst < sonar-project.properties.template > sonar-project.properties"
]
},
"build":{
"shell":[
". ./.env.sh",
"npm i"
]
},
"test":{
"shell":[
". ./.env.sh",
"npm run jasmine"
]
},
"serve":{
"shell":[
". ./.env.sh",
"npm run serve"
]
},
"docker.build":{
"shell":[
". ./.env.sh",
"docker build -t ${COMPONENT_ID}:${COMPONENT_VERSION} ."
]
},
"docker.run":{
"shell":[
". ./.env.sh",
"docker run -d --rm \\",
" -p $COMPONENT_PARAM_PORT:$COMPONENT_PARAM_PORT \\",
" -p $COMPONENT_PARAM_PORTS:$COMPONENT_PARAM_PORTS \\",
" --name ${COMPONENT_ID} ${COMPONENT_ID}:${COMPONENT_VERSION}"
]
},
"docker.save":{
"shell":[
". ./.env.sh",
"docker save -o ${COMPONENT_ID}-${COMPONENT_VERSION}.tar ${COMPONENT_ID}:${COMPONENT_VERSION}"
]
},
"docker.load":{
"shell":[
". ./.env.sh",
"docker load -i ${COMPONENT_ID}-${COMPONENT_VERSION}.tar"
]
},

"docker.stop":{
"shell":[
". ./.env.sh",
"docker stop ${COMPONENT_ID}",
"docker rmi ${COMPONENT_ID}:${COMPONENT_VERSION}"
]
}
}
}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:9.10.1-alpine

# Create app directory
WORKDIR /usr/src/app

# Copy sources
COPY ./package*.json ./
COPY ./src ./src
COPY ./.env.template ./
COPY ./docker-entry.sh ./

# Install app dependencies
RUN apk --update --no-cache add git gettext
RUN npm install --only=production

CMD [ "./docker-entry.sh" ]
2 changes: 0 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash -e

. ./.env.sh
npm i

3 changes: 3 additions & 0 deletions docker-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
envsubst < .env.template > .env
exec npm start
3 changes: 3 additions & 0 deletions docker.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e
. ./.env.sh
docker build -t ${COMPONENT_ID}:${COMPONENT_VERSION} .
3 changes: 3 additions & 0 deletions docker.load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e
. ./.env.sh
docker load -i ${COMPONENT_ID}-${COMPONENT_VERSION}.tar
6 changes: 6 additions & 0 deletions docker.run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e
. ./.env.sh
docker run -d --rm \
-p $COMPONENT_PARAM_PORT:$COMPONENT_PARAM_PORT \
-p $COMPONENT_PARAM_PORTS:$COMPONENT_PARAM_PORTS \
--name ${COMPONENT_ID} ${COMPONENT_ID}:${COMPONENT_VERSION}
3 changes: 3 additions & 0 deletions docker.save.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e
. ./.env.sh
docker save -o ${COMPONENT_ID}-${COMPONENT_VERSION}.tar ${COMPONENT_ID}:${COMPONENT_VERSION}
4 changes: 4 additions & 0 deletions docker.stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e
. ./.env.sh
docker stop ${COMPONENT_ID}
docker rmi ${COMPONENT_ID}:${COMPONENT_VERSION}
28 changes: 7 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions prereq.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash -e
envsubst < .env.template > .env
envsubst < sonar-project.properties.template > sonar-project.properties

./build.sh
1 change: 0 additions & 1 deletion serve.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash -e

. ./.env.sh
npm run serve
3 changes: 0 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/bash -e

. ./.env.sh
npm run jasmine

# enum and run all sh scripts from spec/**/*.sh

0 comments on commit e6ac8e2

Please sign in to comment.