diff --git a/.github/workflows/docker-cd-dev.yml b/.github/workflows/docker-cd-dev.yml new file mode 100644 index 0000000..c0aea68 --- /dev/null +++ b/.github/workflows/docker-cd-dev.yml @@ -0,0 +1,27 @@ +name: Docker Development Image CD + +on: + push: + branches: [ dev ] + workflow_dispatch: + +jobs: + docker-cd: + runs-on: ubuntu-latest + steps: + + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push pims-ui Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: codexrems/pims:REMSvExperimental \ No newline at end of file diff --git a/.github/workflows/docker-cd.yml b/.github/workflows/docker-cd.yml deleted file mode 100644 index ec9b9c7..0000000 --- a/.github/workflows/docker-cd.yml +++ /dev/null @@ -1,35 +0,0 @@ -# name: Docker Image CD - -# on: -# push: -# branches: [ master ] -# workflow_dispatch: - -# jobs: -# docker-cd: -# runs-on: ubuntu-latest -# steps: - -# - name: Checkout Repository -# uses: actions/checkout@v2 - -# - name: Log in to Docker Hub -# uses: docker/login-action@v1 -# with: -# username: ${{ secrets.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_TOKEN }} - -# - name: Build and push Base Node Docker image -# uses: docker/build-push-action@v2 -# with: -# context: . -# file: Dockerfile.base -# push: true -# tags: codexrems/node14-pkg-config:REMSvCurrent - -# - name: Build and push Server Docker image -# uses: docker/build-push-action@v2 -# with: -# context: . -# push: true -# tags: codexrems/pharmacy-information-system:REMSvCurrent diff --git a/.github/workflows/docker-ci-dev.yml b/.github/workflows/docker-ci-dev.yml new file mode 100644 index 0000000..ff6294c --- /dev/null +++ b/.github/workflows/docker-ci-dev.yml @@ -0,0 +1,17 @@ +name: Docker Image CI + +on: + push: + branches: [ dev ] + workflow_dispatch: + +jobs: + docker-ci: + runs-on: ubuntu-latest + steps: + + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Test Server Docker image Builds + run: docker build -f Dockerfile.dev . \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..5337189 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,5 @@ +FROM node:14-alpine +WORKDIR /home/node/app/pims +COPY --chown=node:node . . +RUN npm install +CMD ./dockerRunnerDev.sh \ No newline at end of file diff --git a/dockerRunnerDev.sh b/dockerRunnerDev.sh new file mode 100755 index 0000000..4198943 --- /dev/null +++ b/dockerRunnerDev.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Handle closing application on signal interrupt (ctrl + c) +trap 'kill $CONTINUOUS_INSTALL_PID $SERVER_PID; gradle --stop; exit' INT + +mkdir logs +# Reset log file content for new application boot +echo "*** Logs for continuous installer ***" > ./logs/installer.log +echo "*** Logs for 'npm run start' ***" > ./logs/runner.log + +# Print that the application is starting in watch mode +echo "starting application in watch mode..." + +# Start the continious build listener process +echo "starting continuous installer..." +npm install + +( package_modify_time=$(stat -c %Y package.json) +package_lock_modify_time=$(stat -c %Y package-lock.json) +while sleep 1 +do + new_package_modify_time=$(stat -c %Y package.json) + new_package_lock_modify_time=$(stat -c %Y package-lock.json) + + if [[ "$package_modify_time" != "$new_package_modify_time" ]] || [[ "$package_lock_modify_time" != "$new_package_lock_modify_time" ]] + then + echo "running npm install..." + npm install | tee ./logs/installer.log + fi + + package_modify_time=$new_package_modify_time + package_lock_modify_time=$new_package_lock_modify_time + +done ) & CONTINUOUS_INSTALL_PID=$! + +# Start server process once initial build finishes +( npm run start | tee ./logs/runner.log ) & SERVER_PID=$! + +# Handle application background process exiting +wait $CONTINUOUS_INSTALL_PID $SERVER_PID +EXIT_CODE=$? +echo "application exited with exit code $EXIT_CODE..." + diff --git a/package.json b/package.json index 8210108..fbb4f9a 100644 --- a/package.json +++ b/package.json @@ -40,4 +40,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file