From a7aceff6866a8033ef7920607596bf5526772746 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Wed, 6 May 2020 17:54:32 +0200 Subject: [PATCH] added docker image added ci build --- .dockerignore | 1 + .drone.yml | 18 ++++++++++++++++++ Dockerfile | 7 +++++++ server.ts | 3 ++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .drone.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..dd07674 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,18 @@ +kind: pipeline +name: default + +steps: + - name: build + image: node + commands: + - npm install + - npm run build:ssr + + - name: docker + image: plugins/docker + settings: + repo: samuelph/grafana-statuspage + username: + from_secret: USERNAME + password: + from_secret: PASSWORD diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..41956aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node + +COPY dist/grafana-statuspage /grafana-statuspage + +WORKDIR /app + +ENTRYPOINT ["node", "/grafana-statuspage/server/main.js"] diff --git a/server.ts b/server.ts index 22f38ff..2722cae 100644 --- a/server.ts +++ b/server.ts @@ -8,11 +8,12 @@ import {AppServerModule} from './src/main.server'; import {APP_BASE_HREF} from '@angular/common'; import {existsSync} from 'fs'; import {api} from './src/main.status'; +import {environment} from "./src/environments/environment"; // The Express app is exported so that it can be used by serverless Functions. export function app() { const server = express(); - const distFolder = join(process.cwd(), 'dist/grafana-statuspage/browser'); + const distFolder = environment.production ? '/grafana-statuspage/browser' : join(process.cwd(), 'dist/grafana-statuspage/browser'); const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index'; // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)