Fix pdf viewer when opening in docker.
Have envs for angular.
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ COPY ./booklore-ui/package.json ./booklore-ui/package-lock.json ./
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
COPY ./booklore-ui /angular-app/
|
COPY ./booklore-ui /angular-app/
|
||||||
|
|
||||||
RUN npm run build --prod
|
RUN npm run build --configuration=production
|
||||||
|
|
||||||
# Stage 2: Build the Spring Boot app with Gradle
|
# Stage 2: Build the Spring Boot app with Gradle
|
||||||
FROM gradle:jdk21-alpine AS springboot-build
|
FROM gradle:jdk21-alpine AS springboot-build
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class BooksService {
|
|||||||
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
|
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
|
||||||
byte[] pdfBytes = Files.readAllBytes(new File(FileUtils.getBookFullPath(bookEntity)).toPath());
|
byte[] pdfBytes = Files.readAllBytes(new File(FileUtils.getBookFullPath(bookEntity)).toPath());
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.header(HttpHeaders.CONTENT_TYPE, "application/pdf")
|
.header(HttpHeaders.CONTENT_TYPE, "text/plain")
|
||||||
.body(pdfBytes);
|
.body(pdfBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spring:
|
|||||||
name: booklore-api
|
name: booklore-api
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: org.h2.Driver
|
driver-class-name: org.h2.Driver
|
||||||
url: jdbc:h2:~/my-library-temp/config/db/booklore
|
url: jdbc:h2:~/my-library-temp/config/local/db/booklore
|
||||||
username: sa
|
username: sa
|
||||||
password: password
|
password: password
|
||||||
jpa:
|
jpa:
|
||||||
|
|||||||
@@ -52,6 +52,12 @@
|
|||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
"budgets": [
|
"budgets": [
|
||||||
{
|
{
|
||||||
"type": "initial",
|
"type": "initial",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
export const API_CONFIG = {
|
import {environment} from '../../environments/environment';
|
||||||
BASE_URL: `http://localhost:${window.location.port || 8080}`,
|
|
||||||
BROKER_URL: `ws://localhost:${window.location.port || 8080}/ws`
|
export const API_CONFIG = environment.API_CONFIG;
|
||||||
};
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true,
|
||||||
|
API_CONFIG: {
|
||||||
|
BASE_URL: `http://localhost:${window.location.port}`,
|
||||||
|
BROKER_URL: `ws://localhost:${window.location.port}/ws`,
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: false,
|
||||||
|
API_CONFIG: {
|
||||||
|
BASE_URL: 'http://localhost:8080',
|
||||||
|
BROKER_URL: 'ws://localhost:8080/ws',
|
||||||
|
},
|
||||||
|
};
|
||||||
+2
-2
@@ -2,9 +2,9 @@ version: '3.8'
|
|||||||
services:
|
services:
|
||||||
booklore-app:
|
booklore-app:
|
||||||
container_name: booklore
|
container_name: booklore
|
||||||
image: localhost:5000/booklore-app:v24
|
image: localhost:5000/booklore-app:v33
|
||||||
ports:
|
ports:
|
||||||
- "5050:6060"
|
- "5050:6060"
|
||||||
volumes:
|
volumes:
|
||||||
- /Users/aditya.chandel/my-library-temp/config:/app/config
|
- /Users/aditya.chandel/my-library-temp/config/docker:/app/config
|
||||||
- /Users/aditya.chandel/my-library-temp/books:/app/books
|
- /Users/aditya.chandel/my-library-temp/books:/app/books
|
||||||
@@ -17,6 +17,15 @@ http {
|
|||||||
# Serve Angular UI
|
# Serve Angular UI
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html; # Fallback to index.html for Angular routing
|
try_files $uri $uri/ /index.html; # Fallback to index.html for Angular routing
|
||||||
|
|
||||||
|
location ~* \.mjs$ {
|
||||||
|
# target only *.mjs files
|
||||||
|
# now we can safely override types since we are only
|
||||||
|
# targeting a single file extension.
|
||||||
|
types {
|
||||||
|
text/javascript mjs;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Proxy API requests that start with /api/ to the backend
|
# Proxy API requests that start with /api/ to the backend
|
||||||
|
|||||||
Reference in New Issue
Block a user