Compare commits
2 Commits
061fc51138
...
1067a3ea88
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1067a3ea88 | ||
![]() |
7c5c0de697 |
35
Dockerfile
35
Dockerfile
@ -17,7 +17,7 @@ RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
|||||||
&& pacman -S --noconfirm maven npm pnpm \
|
&& pacman -S --noconfirm maven npm pnpm \
|
||||||
&& pacman -Scc --noconfirm
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
ENV PATH /tmp/node_modules/.bin:$PATH
|
ENV PATH=/tmp/node_modules/.bin:$PATH
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
##
|
##
|
||||||
@ -80,34 +80,25 @@ RUN pnpm static:build
|
|||||||
## Production area:
|
## Production area:
|
||||||
##
|
##
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
FROM bellsoft/liberica-openjdk-alpine-musl:latest
|
||||||
|
|
||||||
#FROM bellsoft/liberica-openjdk-alpine:latest
|
RUN apk add --no-cache wget
|
||||||
## add wget to manage the health check...
|
|
||||||
#RUN apk add --no-cache wget
|
|
||||||
FROM common
|
|
||||||
|
|
||||||
#FROM archlinux:base
|
RUN addgroup -S user \
|
||||||
#RUN pacman -Syu --noconfirm && pacman-db-upgrade
|
&& adduser -S user -G user
|
||||||
## install package
|
|
||||||
#RUN pacman -S --noconfirm jdk-openjdk wget
|
|
||||||
## intall npm
|
|
||||||
#RUN pacman -S --noconfirm npm
|
|
||||||
## clean all the caches Need only on the release environment
|
|
||||||
#RUN pacman -Scc --noconfirm
|
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
|
||||||
|
|
||||||
COPY --from=build_back /tmp/out/maven/*.jar /application/application.jar
|
|
||||||
COPY --from=build_front /tmp/dist /application/front/
|
|
||||||
|
|
||||||
# COPY front/public/icons /application/front/public/icons
|
|
||||||
# COPY front/public/icons /application/front/icons
|
|
||||||
WORKDIR /application/
|
|
||||||
|
|
||||||
|
ENV LANG=C.UTF-8
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
WORKDIR /application/
|
||||||
|
RUN chown user:user -R /application
|
||||||
|
|
||||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
||||||
HEALTHCHECK --start-period=10s --start-interval=2s --interval=30s --timeout=5s --retries=10 \
|
HEALTHCHECK --start-period=10s --start-interval=2s --interval=30s --timeout=5s --retries=10 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/api/health_check || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:80/api/health_check || exit 1
|
||||||
|
|
||||||
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.atriasoft.karusic.WebLauncher"]
|
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.atriasoft.karusic.WebLauncher"]
|
||||||
|
|
||||||
|
COPY --chown=user:user --from=build_back /tmp/out/maven/*.jar /application/application.jar
|
||||||
|
COPY --chown=user:user --from=build_front /tmp/dist /application/front/
|
||||||
|
|
||||||
|
USER user
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.atria-soft</groupId>
|
<groupId>org.atria-soft</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.30.4</version>
|
<version>0.30.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Loopback of logger JDK logging API to SLF4J -->
|
<!-- Loopback of logger JDK logging API to SLF4J -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
|
|
||||||
public class Migration20231126 extends MigrationSqlStep {
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2023-11-26: reorder the migration for the new API of archidata";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
|
|
||||||
public class Migration20240225 extends MigrationSqlStep {
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2024-02-25: change model of thrack to use real json";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20240226 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2024-02-26: convert base with UUID";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20240907 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240907.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2024-09-07: convert data id in uuid";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Migration20240907() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` DROP INDEX `PRIMARY`;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` CHANGE `id` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` ADD PRIMARY KEY `uuid` (`uuid`);
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.atriasoft.archidata.api.DataResource;
|
|
||||||
import org.atriasoft.archidata.dataAccess.DBAccess;
|
|
||||||
import org.atriasoft.archidata.dataAccess.options.AccessDeletedItems;
|
|
||||||
import org.atriasoft.archidata.dataAccess.options.OverrideTableName;
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.atriasoft.karusic.migration.model.CoverConversion;
|
|
||||||
import org.atriasoft.karusic.migration.model.MediaConversion;
|
|
||||||
import org.atriasoft.karusic.migration.model.OIDConversion;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20250104 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2025-01-04: convert base from UUID to OID";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
// Create a simple function to create objectId in the DB (for manual insertion ...)
|
|
||||||
// addAction("""
|
|
||||||
// DELIMITER //
|
|
||||||
//
|
|
||||||
// CREATE FUNCTION generate_objectid()
|
|
||||||
// RETURNS BINARY(12)
|
|
||||||
// DETERMINISTIC
|
|
||||||
// BEGIN
|
|
||||||
// DECLARE ts BINARY(4);
|
|
||||||
// DECLARE random_part BINARY(5);
|
|
||||||
// DECLARE counter BINARY(3);
|
|
||||||
// SET ts = UNHEX(HEX(UNIX_TIMESTAMP()));
|
|
||||||
// SET random_part = UNHEX(HEX(FLOOR(RAND() * POW(2, 40))));
|
|
||||||
// SET counter = UNHEX(HEX(FLOOR(RAND() * POW(2, 24))));
|
|
||||||
// RETURN CONCAT(ts, random_part, counter);
|
|
||||||
// END //
|
|
||||||
//
|
|
||||||
// DELIMITER ;
|
|
||||||
// """);
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` ADD `_id` binary(12) AFTER `uuid`;
|
|
||||||
""");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
for (final OIDConversion elem : datas) {
|
|
||||||
elem._id = new ObjectId();
|
|
||||||
}
|
|
||||||
for (final OIDConversion elem : datas) {
|
|
||||||
da.update(elem, elem.uuid, List.of("_id"), new OverrideTableName("data"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final List<String> tableToTransform = List.of("album", "artist", "gender", "track", "user");
|
|
||||||
for (final String tableName : tableToTransform) {
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers_oid` text NULL;");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
final List<CoverConversion> tableCoverTransforms = da.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
|
||||||
LOGGER.info("Get somes data: {} {}", datas.size(), tableCoverTransforms.size());
|
|
||||||
for (final CoverConversion tableTransform : tableCoverTransforms) {
|
|
||||||
final List<ObjectId> values = new ArrayList<>();
|
|
||||||
if (tableTransform.covers == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (final UUID link : tableTransform.covers) {
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
if (data.uuid.equals(link)) {
|
|
||||||
values.add(data._id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (values.size() != 0) {
|
|
||||||
tableTransform.covers_oid = values;
|
|
||||||
LOGGER.info(" update: {}: {} => {}", tableTransform.id, tableTransform.covers, tableTransform.covers_oid);
|
|
||||||
da.update(tableTransform, tableTransform.id, List.of("covers_oid"), new OverrideTableName(tableName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` DROP `covers`;");
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` CHANGE `covers_oid` `covers` text NULL;");
|
|
||||||
}
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `track` ADD `dataOid` binary(12) AFTER dataId;
|
|
||||||
""");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
final List<MediaConversion> medias = da.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
|
||||||
for (final MediaConversion media : medias) {
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
if (data.uuid.equals(media.dataId)) {
|
|
||||||
media.dataOid = data._id;
|
|
||||||
da.update(media, media.id, List.of("dataOid"), new OverrideTableName("track"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `track` DROP `dataId`;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `track` CHANGE `dataOid` `dataId` binary(12) NOT NULL;
|
|
||||||
""");
|
|
||||||
// Move the files...
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
final String origin = DataResource.getFileDataOld(data.uuid);
|
|
||||||
final String destination = DataResource.getFileData(data._id);
|
|
||||||
LOGGER.info("move file = {}", origin);
|
|
||||||
LOGGER.info(" ==> {}", destination);
|
|
||||||
try {
|
|
||||||
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
|
|
||||||
} catch (final NoSuchFileException ex) {
|
|
||||||
LOGGER.warn("Fail to move file : {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` DROP `uuid`;
|
|
||||||
""");
|
|
||||||
// addAction("""
|
|
||||||
// ALTER TABLE `data` CHANGE `_id` `_id` BINARY(12) DEFAULT (generate_objectid());
|
|
||||||
// """);
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` ADD PRIMARY KEY `_id` (`_id`);
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package org.atriasoft.karusic.migration;
|
|
||||||
|
|
||||||
import org.atriasoft.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20250414 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2025-04-14: update constraints";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `artist`
|
|
||||||
CHANGE `birth` `birth` timestamp(3) NULL AFTER `surname`,
|
|
||||||
CHANGE `death` `death` timestamp(3) NULL AFTER `birth`;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `album`
|
|
||||||
CHANGE `publication` `publication` timestamp(3) NULL AFTER `description`;
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class Migration20250427 extends MigrationSqlStep {
|
public class Migration20250427 extends MigrationSqlStep {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20250427.class);
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
@ -73,10 +73,8 @@ public class Migration20250427 extends MigrationSqlStep {
|
|||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
addAction((final DBAccess daMongo) -> {
|
addAction((final DBAccess daMongo) -> {
|
||||||
// Create the previous connection on SQL:
|
// Create the previous connection on SQL:
|
||||||
final DbConfig configSQL = new DbConfig("mysql", ConfigBaseVariable.getDBHost(), (short) 3906,
|
final DbConfig configSQL = new DbConfig("mysql", "db", (short) 3306, ConfigBaseVariable.getDBLogin(), ConfigBaseVariable.getDBPassword(), ConfigBaseVariable.getDBName(),
|
||||||
// final DbConfig config = new DbConfig("mysql", "db", (short) 3306,
|
ConfigBaseVariable.getDBKeepConnected(), List.of(ConfigBaseVariable.getBbInterfacesClasses()));
|
||||||
ConfigBaseVariable.getDBLogin(), ConfigBaseVariable.getDBPassword(), ConfigBaseVariable.getDBName(), ConfigBaseVariable.getDBKeepConnected(),
|
|
||||||
List.of(ConfigBaseVariable.getBbInterfacesClasses()));
|
|
||||||
try (final DBAccess daSQL = DBAccess.createInterface(configSQL)) {
|
try (final DBAccess daSQL = DBAccess.createInterface(configSQL)) {
|
||||||
final List<Data> allData = daSQL.gets(Data.class, new ReadAllColumn(), new AccessDeletedItems());
|
final List<Data> allData = daSQL.gets(Data.class, new ReadAllColumn(), new AccessDeletedItems());
|
||||||
final List<AlbumOld> allOldAlbums = daSQL.gets(AlbumOld.class, new ReadAllColumn(), new AccessDeletedItems());
|
final List<AlbumOld> allOldAlbums = daSQL.gets(AlbumOld.class, new ReadAllColumn(), new AccessDeletedItems());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user