Deploy on docker (not productive yet!)
All checks were successful
Java CI with Maven / build (push) Successful in 59s

This commit is contained in:
Sebastian Böckelmann 2023-11-12 16:43:39 +01:00
parent f000b36710
commit 157126d404
18 changed files with 65 additions and 63 deletions

View File

@ -5,9 +5,17 @@
</component>
<component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Fix wrong date">
<change afterPath="$PROJECT_DIR$/../frontend/nginx.conf" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../frontend/proxy.conf.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/AdvancedTaskSchedule.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/AdvancedTaskSchedule.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../docker-compose.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/angular.json" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/angular.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/nginx/nginx.conf.template" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/nginx/run_nginx.sh" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../openapi.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../openapi.yaml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -26,7 +34,7 @@
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$/.." value="test-failing" />
<entry key="$PROJECT_DIR$/.." value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
@ -34,6 +42,9 @@
<component name="JpbToolWindowState">
<option name="isToolWindowVisible" value="false" />
</component>
<component name="MavenRunner">
<option name="skipTests" value="true" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 6

View File

@ -31,7 +31,7 @@ spring.jpa.open-in-view=false
spring.data.rest.base-path=/api
# Spring Server setup
server.address=127.0.0.1
server.address=0.0.0.0
server.port=8080
server.compression.enabled=true
server.http2.enabled=true
@ -42,3 +42,4 @@ spring.servlet.multipart.max-request-size=4196KB
demo.webapp.jwtSecret=demoWebappSecretKey
demo.webapp.jwtExpirationMS=86400000
spring.jackson.time-zone=UTC
server.servlet.session.cookie.samesite=None

View File

@ -4,7 +4,7 @@ services:
db:
image: mariadb:latest
container_name: template_mysql
container_name: timemanager-db
environment:
MYSQL_ROOT_PASSWORD: edkvcjReDxJ9Z8hq
backend:
@ -14,12 +14,15 @@ services:
links:
- "db:app_db"
environment:
SERVER_ADDRESS: 0.0.0.0
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: edkvcjReDxJ9Z8hq
SPRING_DATASOURCE_URL: jdbc:mariadb://app_db:3306/restservice?createDatabaseIfNotExist=true&autoReconnect=true
depends_on:
- "db"
restart: always
ports:
- "8080:8080"
frontend:
build:
context: ./frontend
@ -27,6 +30,8 @@ services:
restart: always
links:
- backend:backend
depends_on:
- "backend"
ports:
- "4200:80"
environment:

View File

@ -1,29 +1,18 @@
FROM node:16-alpine as builder
### STAGE 1: Build ###
FROM node:18.17.1 AS build
WORKDIR /app
COPY package*.json ./
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
WORKDIR /ng-app
RUN npm install
COPY . .
RUN npm run build --prod
RUN $(npm bin)/ng build --configuration=production --build-optimizer
FROM nginx:stable-alpine
### STAGE 2: Deploy ###
FROM nginx:latest
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install iputils-ping -y
COPY --from=build /app/dist/frontend /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
COPY nginx/nginx.conf.template /
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /ng-app/dist/frontend/ /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx/html/
COPY nginx/run_nginx.sh /
CMD ["sh", "/run_nginx.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -38,8 +38,8 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",

View File

@ -1,7 +1,6 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
@ -14,12 +13,6 @@ http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '${DOLLAR}remote_addr - ${DOLLAR}remote_user [${DOLLAR}time_local] "${DOLLAR}request" '
'${DOLLAR}status ${DOLLAR}body_bytes_sent "${DOLLAR}http_referer" '
'"${DOLLAR}http_user_agent" "${DOLLAR}http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
@ -40,12 +33,17 @@ http {
add_header "Access-Control-Allow-Methods" 'GET, POST, OPTIONS, PUT, DELETE';
add_header "Access-Control-Allow-Headers" 'X-Requested-With,Accept,Content-Type, Origin';
location / {
try_files ${DOLLAR}uri ${DOLLAR}uri/ /index.html;
location /api {
proxy_pass http://backend/;
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Methods" 'GET, POST, OPTIONS, PUT, DELETE';
add_header "Access-Control-Allow-Headers" 'X-Requested-With,Accept,Content-Type, Origin';
}
location /api {
proxy_pass ${BACKEND_URL};
}
location / {
try_files $uri $uri/ /index.html =404;
}
}
}

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# generate nginx-configuration (insert env variables)
export DOLLAR='$'
envsubst < ./nginx.conf.template > /etc/nginx/nginx.conf
# start nginx
exec nginx -g "daemon off;"

6
frontend/proxy.conf.json Normal file
View File

@ -0,0 +1,6 @@
{
"/api": {
"target": "http://backend",
"secure": false
}
}

View File

@ -35,7 +35,7 @@ import { Configuration } from '../configurat
})
export class AccountService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -31,7 +31,7 @@ import { Configuration } from '../configurat
})
export class HistoryService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -36,7 +36,7 @@ import { Configuration } from '../configurat
})
export class LoginService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -34,7 +34,7 @@ import { Configuration } from '../configurat
})
export class PropertiesService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -36,7 +36,7 @@ import { Configuration } from '../configurat
})
export class ScheduleService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -35,7 +35,7 @@ import { Configuration } from '../configurat
})
export class TaskService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -36,7 +36,7 @@ import { Configuration } from '../configurat
})
export class TaskgroupService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -34,7 +34,7 @@ import { Configuration } from '../configurat
})
export class UsersService {
protected basePath = 'http://localhost:8080/api';
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

View File

@ -1,3 +1,4 @@
export const environment = {
production: true
production: true,
api: "/api"
};

View File

@ -3,7 +3,7 @@ info:
title: API Title
version: '1.0'
servers:
- url: http://localhost:8080/api
- url: http://127.0.0.1:8080/api
paths:
/auth/signin:
post: