Move package to com.backend.search.kodik.service...
and add Dockerfile
This commit is contained in:
36
Dockerfile.prod
Normal file
36
Dockerfile.prod
Normal file
@ -0,0 +1,36 @@
|
||||
FROM eclipse-temurin:21 AS app-build
|
||||
ENV RELEASE=21
|
||||
|
||||
WORKDIR /opt/build
|
||||
COPY ./target/*.jar ./application.jar
|
||||
|
||||
RUN java -Djarmode=layertools -jar application.jar extract
|
||||
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` \
|
||||
--strip-debug \
|
||||
--no-man-pages \
|
||||
--no-header-files \
|
||||
--compress=2 \
|
||||
--output jdk
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
||||
ARG BUILD_PATH=/opt/build
|
||||
ENV JAVA_HOME=/opt/jdk
|
||||
ENV PATH="${JAVA_HOME}/bin:${PATH}"
|
||||
|
||||
RUN groupadd --gid 1000 spring-app \
|
||||
&& useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app
|
||||
|
||||
USER spring-app:spring-app
|
||||
WORKDIR /opt/workspace
|
||||
|
||||
COPY --from=app-build $BUILD_PATH/jdk $JAVA_HOME
|
||||
COPY --from=app-build $BUILD_PATH/spring-boot-loader/ ./
|
||||
COPY --from=app-build $BUILD_PATH/dependencies/ ./
|
||||
COPY --from=app-build $BUILD_PATH/snapshot-dependencies/ ./
|
||||
COPY --from=app-build $BUILD_PATH/application/ ./
|
||||
|
||||
EXPOSE 8080/tcp
|
||||
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.backend.search.service.anyame_backend;
|
||||
package com.backend.search.kodik.service.anyame_backend;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@ -19,7 +19,7 @@ public class AnyameBackendApplication {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedOrigins("http://localhost:3000");
|
||||
registry.addMapping("/**").allowedOrigins("http://localhost:3000", "http://localhost:3001");
|
||||
}
|
||||
};
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.backend.search.service.anyame_backend.api;
|
||||
package com.backend.search.kodik.service.anyame_backend.api;
|
||||
|
||||
import com.backend.search.kodik.service.anyame_backend.api.model.KodikResponse;
|
||||
|
||||
import com.backend.search.service.anyame_backend.api.model.KodikResponse;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
@ -14,7 +15,6 @@ public interface KodikAPI {
|
||||
@Field("token") String token,
|
||||
@Field("title") String title,
|
||||
@Field("limit") int limit,
|
||||
@Field("with_material_data") int withMaterialData
|
||||
);
|
||||
@Field("with_material_data") int withMaterialData);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.backend.search.service.anyame_backend.api.model;
|
||||
package com.backend.search.kodik.service.anyame_backend.api.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@ -45,6 +45,18 @@ public class KodikResponse {
|
||||
public String createdAt;
|
||||
@JsonProperty("updated_at")
|
||||
public String updatedAt;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Result [id=" + id + ", type=" + type + ", link=" + link + ", title=" + title + ", titleOrig="
|
||||
+ titleOrig + ", otherTitle=" + otherTitle + ", translation=" + translation + ", year=" + year
|
||||
+ ", lastSeason=" + lastSeason + ", lastEpisode=" + lastEpisode + ", episodesCount=" + episodesCount
|
||||
+ ", kinopoiskId=" + kinopoiskId + ", imdbId=" + imdbId + ", worldartLink=" + worldartLink
|
||||
+ ", shikimoriId=" + shikimoriId + ", quality=" + quality + ", camrip=" + camrip + ", lgbt=" + lgbt
|
||||
+ ", blockedCountries=" + blockedCountries + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt
|
||||
+ ", materialData=" + materialData + ", screenshots=" + screenshots + "]";
|
||||
}
|
||||
|
||||
@JsonProperty("material_data")
|
||||
public MaterialData materialData;
|
||||
public List<String> screenshots;
|
||||
@ -57,4 +69,9 @@ public class KodikResponse {
|
||||
public String type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KodikResponse [total=" + total + ", results=" + results + ", toString()=" + super.toString() + "]";
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.backend.search.service.anyame_backend.api.model;
|
||||
package com.backend.search.kodik.service.anyame_backend.api.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,4 +1,4 @@
|
||||
package com.backend.search.service.anyame_backend.component;
|
||||
package com.backend.search.kodik.service.anyame_backend.component;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
@ -1,8 +1,10 @@
|
||||
package com.backend.search.service.anyame_backend.config;
|
||||
package com.backend.search.kodik.service.anyame_backend.config;
|
||||
|
||||
import com.backend.search.service.anyame_backend.api.KodikAPI;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.backend.search.kodik.service.anyame_backend.api.KodikAPI;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.backend.search.service.anyame_backend.controller;
|
||||
package com.backend.search.kodik.service.anyame_backend.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.backend.search.service.anyame_backend.api.KodikAPI;
|
||||
import com.backend.search.service.anyame_backend.api.model.KodikResponse;
|
||||
import com.backend.search.service.anyame_backend.component.KodikAPITokenProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -10,9 +9,12 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import retrofit2.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.backend.search.kodik.service.anyame_backend.api.KodikAPI;
|
||||
import com.backend.search.kodik.service.anyame_backend.api.model.KodikResponse;
|
||||
import com.backend.search.kodik.service.anyame_backend.component.KodikAPITokenProvider;
|
||||
|
||||
import retrofit2.Response;
|
||||
|
||||
@RestController
|
||||
public class SearchController {
|
||||
@ -35,6 +37,7 @@ public class SearchController {
|
||||
response.message());
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "bad response, code: " + response.code());
|
||||
}
|
||||
log.info("search result {}", response.body());
|
||||
return response.body();
|
||||
} catch (IOException e) {
|
||||
log.warn("i/o error", e);
|
@ -1 +1,2 @@
|
||||
spring.application.name=anyame-backend
|
||||
server.error.include-message=always
|
||||
|
Reference in New Issue
Block a user