Skip to content

Commit c109923

Browse files
authored
Merge pull request #2 from mcode/rems-286-pimsCICD
Rems 286 pims cicd
2 parents 7e3663f + 2b3c40e commit c109923

6 files changed

Lines changed: 93 additions & 36 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Docker Development Image CD
2+
3+
on:
4+
push:
5+
branches: [ dev ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
docker-cd:
10+
runs-on: ubuntu-latest
11+
steps:
12+
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@v1
18+
with:
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_TOKEN }}
21+
22+
- name: Build and push pims-ui Docker image
23+
uses: docker/build-push-action@v2
24+
with:
25+
context: .
26+
push: true
27+
tags: codexrems/pims:REMSvExperimental

.github/workflows/docker-cd.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ dev ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
docker-ci:
10+
runs-on: ubuntu-latest
11+
steps:
12+
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Test Server Docker image Builds
17+
run: docker build -f Dockerfile.dev .

Dockerfile.dev

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM node:14-alpine
2+
WORKDIR /home/node/app/pims
3+
COPY --chown=node:node . .
4+
RUN npm install
5+
CMD ./dockerRunnerDev.sh

dockerRunnerDev.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
# Handle closing application on signal interrupt (ctrl + c)
4+
trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID; gradle --stop; exit' INT
5+
6+
mkdir logs
7+
# Reset log file content for new application boot
8+
echo "*** Logs for continuous installer ***" > ./logs/installer.log
9+
echo "*** Logs for 'npm run start' ***" > ./logs/runner.log
10+
11+
# Print that the application is starting in watch mode
12+
echo "starting application in watch mode..."
13+
14+
# Start the continious build listener process
15+
echo "starting continuous installer..."
16+
npm install
17+
18+
( package_modify_time=$(stat -c %Y package.json)
19+
package_lock_modify_time=$(stat -c %Y package-lock.json)
20+
while sleep 1
21+
do
22+
new_package_modify_time=$(stat -c %Y package.json)
23+
new_package_lock_modify_time=$(stat -c %Y package-lock.json)
24+
25+
if [[ "$package_modify_time" != "$new_package_modify_time" ]] || [[ "$package_lock_modify_time" != "$new_package_lock_modify_time" ]]
26+
then
27+
echo "running npm install..."
28+
npm install | tee ./logs/installer.log
29+
fi
30+
31+
package_modify_time=$new_package_modify_time
32+
package_lock_modify_time=$new_package_lock_modify_time
33+
34+
done ) & CONTINUOUS_INSTALL_PID=$!
35+
36+
# Start server process once initial build finishes
37+
( npm run start | tee ./logs/runner.log ) & SERVER_PID=$!
38+
39+
# Handle application background process exiting
40+
wait $CONTINUOUS_INSTALL_PID $SERVER_PID
41+
EXIT_CODE=$?
42+
echo "application exited with exit code $EXIT_CODE..."
43+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@
4040
"last 1 safari version"
4141
]
4242
}
43-
}
43+
}

0 commit comments

Comments
 (0)