Compare commits
3 Commits
e37a9478cb
...
867edab39c
Author | SHA1 | Date | |
---|---|---|---|
867edab39c | |||
39ee53e262 | |||
32b16ddf31 |
@ -1,19 +1,29 @@
|
|||||||
|
# Build
|
||||||
|
FROM maven:3.9.6-eclipse-temurin-21 AS builder
|
||||||
|
WORKDIR /workspace
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn dependency:go-offline -B
|
||||||
|
COPY src ./src
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
# Create optimized runtime
|
||||||
FROM eclipse-temurin:21 AS app-build
|
FROM eclipse-temurin:21 AS app-build
|
||||||
ENV RELEASE=21
|
ENV RELEASE=21
|
||||||
|
|
||||||
WORKDIR /opt/build
|
WORKDIR /opt/build
|
||||||
COPY ./target/*.jar ./application.jar
|
COPY --from=builder /workspace/target/*.jar ./application.jar
|
||||||
|
|
||||||
RUN java -Djarmode=layertools -jar application.jar extract
|
RUN java -Djarmode=layertools -jar application.jar extract
|
||||||
RUN $JAVA_HOME/bin/jlink \
|
RUN $JAVA_HOME/bin/jlink \
|
||||||
--add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar` \
|
--add-modules $(jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar),jdk.crypto.ec,jdk.security.auth,jdk.crypto.cryptoki \
|
||||||
--strip-debug \
|
--strip-debug \
|
||||||
--no-man-pages \
|
--no-man-pages \
|
||||||
--no-header-files \
|
--no-header-files \
|
||||||
--compress=2 \
|
--compress=2 \
|
||||||
--output jdk
|
--output jdk
|
||||||
|
|
||||||
FROM debian:buster-slim
|
# Run
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
ARG BUILD_PATH=/opt/build
|
ARG BUILD_PATH=/opt/build
|
||||||
ENV JAVA_HOME=/opt/jdk
|
ENV JAVA_HOME=/opt/jdk
|
||||||
@ -22,6 +32,10 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
|
|||||||
RUN groupadd --gid 1000 spring-app \
|
RUN groupadd --gid 1000 spring-app \
|
||||||
&& useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app
|
&& useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends ca-certificates && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
USER spring-app:spring-app
|
USER spring-app:spring-app
|
||||||
WORKDIR /opt/workspace
|
WORKDIR /opt/workspace
|
||||||
|
|
||||||
|
11
compose.yml
Normal file
11
compose.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
extractor:
|
||||||
|
image: anyame-extractor:latest
|
||||||
|
ports:
|
||||||
|
- 8081:8080
|
||||||
|
env_file: .env
|
||||||
|
networks:
|
||||||
|
- anyame
|
||||||
|
networks:
|
||||||
|
anyame:
|
||||||
|
driver: bridge
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class KodikAPITokenProvider {
|
public class KodikAPITokenProvider {
|
||||||
@Value("${KODIK_TOKEN}")
|
@Value("${kodik.token}")
|
||||||
private String kodikToken;
|
private String kodikToken;
|
||||||
|
|
||||||
public String getKodikToken() {
|
public String getKodikToken() {
|
||||||
|
@ -2,6 +2,8 @@ package com.backend.extractor.kodik.service.anyame_backend.controller;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -23,7 +25,7 @@ import com.backend.extractor.kodik.service.anyame_backend.service.KodikURLDecode
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/extract")
|
@RequestMapping("/extract")
|
||||||
public class ExtractController {
|
public class ExtractController {
|
||||||
|
Logger logger = LoggerFactory.getLogger(ExtractController.class);
|
||||||
private final KodikExtractService extractService;
|
private final KodikExtractService extractService;
|
||||||
private final KodikURLDecoderService decoderService;
|
private final KodikURLDecoderService decoderService;
|
||||||
|
|
||||||
@ -41,14 +43,18 @@ public class ExtractController {
|
|||||||
links.decodeLinks(decoderService);
|
links.decodeLinks(decoderService);
|
||||||
return links;
|
return links;
|
||||||
} catch (KodikExtractionException e) {
|
} catch (KodikExtractionException e) {
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadat", e);
|
logger.error("cannot retrieve metadata", e);
|
||||||
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadata", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
||||||
} catch (KodikPlayerNotFoundException e) {
|
} catch (KodikPlayerNotFoundException e) {
|
||||||
|
logger.error("cannoot find player", e);
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "player not found");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "player not found");
|
||||||
} catch (KodikAPINotFoundException e) {
|
} catch (KodikAPINotFoundException e) {
|
||||||
|
logger.error("api endpoint not found", e);
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "api endpoint not found");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "api endpoint not found");
|
||||||
} catch (KodikDecryptionException e) {
|
} catch (KodikDecryptionException e) {
|
||||||
|
logger.error("cannot decrypt link", e);
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot decode links");
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot decode links");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package com.backend.extractor.kodik.service.anyame_backend.controller;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -21,6 +23,7 @@ import retrofit2.Response;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/metadata")
|
@RequestMapping("/metadata")
|
||||||
public class MetadataController {
|
public class MetadataController {
|
||||||
|
Logger logger = LoggerFactory.getLogger(MetadataController.class);
|
||||||
private final KodikPlayerAPI kodikPlayerAPI;
|
private final KodikPlayerAPI kodikPlayerAPI;
|
||||||
private final KodikAPITokenProvider tokenProvider;
|
private final KodikAPITokenProvider tokenProvider;
|
||||||
private final KodikExtractService extractService;
|
private final KodikExtractService extractService;
|
||||||
@ -45,7 +48,8 @@ public class MetadataController {
|
|||||||
String url = responseResult.getLink();
|
String url = responseResult.getLink();
|
||||||
return extractService.getMetadata(url);
|
return extractService.getMetadata(url);
|
||||||
} catch (KodikExtractionException e) {
|
} catch (KodikExtractionException e) {
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadat", e);
|
logger.error("cannot retrieve metadata", e);
|
||||||
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadata", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
||||||
}
|
}
|
||||||
@ -63,6 +67,7 @@ public class MetadataController {
|
|||||||
String url = responseResult.getLink();
|
String url = responseResult.getLink();
|
||||||
return extractService.getMetadata(url);
|
return extractService.getMetadata(url);
|
||||||
} catch (KodikExtractionException e) {
|
} catch (KodikExtractionException e) {
|
||||||
|
logger.error("cannot retrieve metadata", e);
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadata", e);
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "cannot retrieve metadata", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "i/o error");
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
spring.application.name=anyame-backend
|
spring.application.name=anyame-backend
|
||||||
server.error.include-message=always
|
server.error.include-message=always
|
||||||
|
kodik.token=${KODIK_TOKEN}
|
||||||
|
Reference in New Issue
Block a user