From 49480c5d67397283ac0f3e7a918dd1d6610f5225 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 9 Nov 2021 01:55:57 +0100 Subject: [PATCH] Add production build and deploy command --- frontend/.gitignore => .gitignore | 4 ++-- docker-compose.yml | 2 +- frontend/Dockerfile | 8 +++++--- frontend/docker.sh | 10 ++++++++++ frontend/package.json | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) rename frontend/.gitignore => .gitignore (96%) diff --git a/frontend/.gitignore b/.gitignore similarity index 96% rename from frontend/.gitignore rename to .gitignore index c47f93c..3eb038c 100644 --- a/frontend/.gitignore +++ b/.gitignore @@ -3,14 +3,14 @@ *.log # compiled output -/dist +dist /tmp /out-tsc # Only exists if Bazel was run /bazel-out # dependencies -/node_modules +node_modules # profiling files chrome-profiler-events*.json diff --git a/docker-compose.yml b/docker-compose.yml index 9fb3cfd..0f24e23 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: volumes: - ./frontend:/home/node/app environment: - - NODE_ENV=development + - COMMAND=run networks: default: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 15e8ac2..209685b 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -2,8 +2,10 @@ FROM node:16 EXPOSE 4200 -COPY docker.sh /docker.sh -RUN chmod +x docker.sh WORKDIR /home/node/app -ENTRYPOINT /docker.sh +ENTRYPOINT [ "/docker.sh" ] +CMD [ "run" ] + +COPY docker.sh /docker.sh +RUN chmod +x /docker.sh diff --git a/frontend/docker.sh b/frontend/docker.sh index 26b9cc0..d1f39f7 100644 --- a/frontend/docker.sh +++ b/frontend/docker.sh @@ -1,3 +1,13 @@ +#!/usr/bin/env bash + +if [ $COMMAND == "deploy" ]; then + npm run buildProd + npm install -g firebase-tools + firebase login --no-localhost + firebase deploy + exit 0 +fi + echo "Installing packages" npm install echo "Running application" diff --git a/frontend/package.json b/frontend/package.json index 301e947..1e76a68 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,6 +5,7 @@ "ng": "ng", "start": "ng serve --host 0.0.0.0 --disable-host-check", "build": "ng build", + "buildProd": "ng build --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e"