mirror of
https://github.com/booklore-app/booklore.git
synced 2025-12-23 22:28:11 -05:00
Fix pdf viewer when opening in docker.
Have envs for angular.
This commit is contained in:
@@ -7,7 +7,7 @@ COPY ./booklore-ui/package.json ./booklore-ui/package-lock.json ./
|
||||
RUN npm install
|
||||
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
|
||||
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));
|
||||
byte[] pdfBytes = Files.readAllBytes(new File(FileUtils.getBookFullPath(bookEntity)).toPath());
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_TYPE, "application/pdf")
|
||||
.header(HttpHeaders.CONTENT_TYPE, "text/plain")
|
||||
.body(pdfBytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ spring:
|
||||
name: booklore-api
|
||||
datasource:
|
||||
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
|
||||
password: password
|
||||
jpa:
|
||||
|
||||
@@ -52,6 +52,12 @@
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export const API_CONFIG = {
|
||||
BASE_URL: `http://localhost:${window.location.port || 8080}`,
|
||||
BROKER_URL: `ws://localhost:${window.location.port || 8080}/ws`
|
||||
};
|
||||
import {environment} from '../../environments/environment';
|
||||
|
||||
export const API_CONFIG = environment.API_CONFIG;
|
||||
|
||||
7
booklore-ui/src/environments/environment.prod.ts
Normal file
7
booklore-ui/src/environments/environment.prod.ts
Normal file
@@ -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`,
|
||||
},
|
||||
};
|
||||
7
booklore-ui/src/environments/environment.ts
Normal file
7
booklore-ui/src/environments/environment.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
API_CONFIG: {
|
||||
BASE_URL: 'http://localhost:8080',
|
||||
BROKER_URL: 'ws://localhost:8080/ws',
|
||||
},
|
||||
};
|
||||
@@ -2,9 +2,9 @@ version: '3.8'
|
||||
services:
|
||||
booklore-app:
|
||||
container_name: booklore
|
||||
image: localhost:5000/booklore-app:v24
|
||||
image: localhost:5000/booklore-app:v33
|
||||
ports:
|
||||
- "5050:6060"
|
||||
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
|
||||
@@ -17,6 +17,15 @@ http {
|
||||
# Serve Angular UI
|
||||
location / {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user