ソースを参照

Added configurations for 'docker only' development

Lukas Cerny 1 年間 前
コミット
a5bca5a8b7
6 ファイル変更78 行追加14 行削除
  1. 15 4
      Dockerfile
  2. 35 2
      angular.json
  3. 0 8
      compose.yml
  4. 20 0
      docker-compose.yml
  5. 1 0
      package.json
  6. 7 0
      src/environments/environment.dev.ts

+ 15 - 4
Dockerfile

@@ -1,11 +1,22 @@
-FROM node:21-alpine AS angularApp
+FROM node:20-alpine AS build-prod
 WORKDIR /usr/src/app
 COPY package.json package-lock.json ./
-RUN npm install --force
+RUN npm install --force --loglevel=error
 COPY . .
 RUN npm run build
 
+FROM node:20-alpine AS build-dev
+WORKDIR /usr/src/app
+COPY package.json package-lock.json ./
+RUN npm install
+COPY . .
+RUN npm run build-dev
+
+
+FROM nginx:1.25.3-alpine AS run-prod
+COPY nginx.conf /etc/nginx/nginx.conf
+COPY --from=build-prod /usr/src/app/dist/SensLog /usr/share/nginx/html
 
-FROM nginx:1.25.3-alpine
+FROM nginx:1.25.3-alpine AS run-dev
 COPY nginx.conf /etc/nginx/nginx.conf
-COPY --from=angularApp /usr/src/app/dist/SensLog /usr/share/nginx/html
+COPY --from=build-dev /usr/src/app/dist/SensLog /usr/share/nginx/html

+ 35 - 2
angular.json

@@ -67,8 +67,35 @@
               "budgets": [
                 {
                   "type": "initial",
-                  "maximumWarning": "2mb",
-                  "maximumError": "5mb"
+                  "maximumWarning": "3mb",
+                  "maximumError": "7mb"
+                },
+                {
+                  "type": "anyComponentStyle",
+                  "maximumWarning": "6kb",
+                  "maximumError": "10kb"
+                }
+              ]
+            },
+            "dev": {
+              "fileReplacements": [
+                {
+                  "replace": "src/environments/environment.ts",
+                  "with": "src/environments/environment.dev.ts"
+                }
+              ],
+              "optimization": true,
+              "outputHashing": "all",
+              "sourceMap": true,
+              "namedChunks": false,
+              "extractLicenses": true,
+              "vendorChunk": false,
+              "buildOptimizer": true,
+              "budgets": [
+                {
+                  "type": "initial",
+                  "maximumWarning": "3mb",
+                  "maximumError": "7mb"
                 },
                 {
                   "type": "anyComponentStyle",
@@ -88,6 +115,9 @@
           "configurations": {
             "production": {
               "browserTarget": "SensLog:build:production"
+            },
+            "dev": {
+              "browserTarget": "SensLog:build:dev"
             }
           }
         },
@@ -136,6 +166,9 @@
           "configurations": {
             "production": {
               "devServerTarget": "SensLog:serve:production"
+            },
+            "dev": {
+              "devServerTarget": "SensLog:serve:dev"
             }
           }
         }

+ 0 - 8
compose.yml

@@ -1,8 +0,0 @@
-version: '3.8'
-services:
-  sensclient:
-    build: .
-    image: senslog
-    container_name: senslog_client
-    ports:
-      - 8080:80

+ 20 - 0
docker-compose.yml

@@ -0,0 +1,20 @@
+version: '3.9'
+
+services:
+  client-prod:
+    container_name: senslog_client
+    image: senslog/client
+    build:
+      target: run-prod
+      context: .
+    ports:
+      - 4200:80
+
+  client-dev:
+    container_name: senslog_client_dev
+    image: senslog/client-dev
+    build:
+      target: run-dev
+      context: .
+    ports:
+      - 4200:80

+ 1 - 0
package.json

@@ -5,6 +5,7 @@
     "ng": "ng",
     "start": "ng serve",
     "build": "ng build --configuration production",
+    "build-dev": "ng build --configuration dev",
     "build-stage": "ng build --configuration production --base-href /senslog-staging",
     "test": "ng test",
     "lint": "ng lint",

+ 7 - 0
src/environments/environment.dev.ts

@@ -0,0 +1,7 @@
+export const environment = {
+  production: false,
+  baseHref: '/senslog-dev',
+  useMock: false,
+  sensLogBaseUrl: 'http://localhost:8080/DBService_war',
+  hslayersAssetsPath: './hslayers-ng/assets'
+};