Skip to content

Commit

Permalink
Aloitettu Lampi-siirtäjän muutos Node-sovelluksesta Java-sovellukseksi
Browse files Browse the repository at this point in the history
  • Loading branch information
augustk committed Jan 15, 2025
1 parent 158b41f commit 36b7351
Show file tree
Hide file tree
Showing 16 changed files with 525 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-lampi-siirtaja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Helsinki"

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -36,5 +54,8 @@ jobs:
IMAGE_TAG: ga-${{ github.run_number }}
run: |
cd lampi-siirtaja-container
cd lampi-siirtaja
mvn -B clean package
cd -
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ cdk.out
#Mac metadata
.DS_Store
dbt/package-lock.yml

target
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.0
1 change: 1 addition & 0 deletions cdk/lib/ecs-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ export class EcsStack extends cdk.Stack {
memoryLimitMiB: 6144,
environment: {
POSTGRES_HOST: `raportointi.db.${config.publicHostedZone}`,
POSTGRES_PORT: '5432',
DB_USERNAME: 'app',
LAMPI_S3_BUCKET: lampiSiirtajaTempS3Bucket.bucketName,
OVARA_LAMPI_SIIRTAJA_BUCKET: lampiSiirtajaS3Bucket.bucketName,
Expand Down
4 changes: 2 additions & 2 deletions lampi-siirtaja-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:20-alpine3.20
FROM amazoncorretto:21-alpine-full
RUN apk upgrade --no-cache
RUN apk --no-cache add bash

WORKDIR /root/
COPY ./run.sh ./run.sh
COPY ./install.sh ./install.sh
ADD ./lampi-siirtaja ./lampi-siirtaja
ADD ./lampi-siirtaja/target/ovara-lampi-siirtaja-jar-with-dependencies.jar ./ovara-lampi-siirtaja.jar
RUN \
bash install.sh && \
rm install.sh
Expand Down
24 changes: 12 additions & 12 deletions lampi-siirtaja-container/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ case "$(uname -m)" in
esac
echo $ARCHITECTURE

echo "Installing needed software"
apk --no-cache add \
python3 \
py3-pip \
libpq-dev \
g++ \
make
#echo "Installing needed software"
#apk --no-cache add \
# python3 \
# py3-pip \
# libpq-dev \
# g++ \
# make

echo "Listing contents of /root folder"
ls -Al /root

echo "Listing contents of /root/lampi-siirtaja folder"
ls -Al /root/lampi-siirtaja
#echo "Listing contents of /root/lampi-siirtaja folder"
#ls -Al /root/lampi-siirtaja

echo "Installing dependencies with npm"
cd /root/lampi-siirtaja
npm ci
#echo "Installing dependencies with npm"
#cd /root/lampi-siirtaja
#npm ci
154 changes: 154 additions & 0 deletions lampi-siirtaja-container/lampi-siirtaja/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fi.oph.opintopolku.ovara</groupId>
<artifactId>lampi-siirtaja</artifactId>
<version>1.0-SNAPSHOT</version>

<name>lampi-siirtaja</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.780</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.4.0-jre</version>
</dependency>
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>


<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.8.1</version>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.4</version>
</dependency>



<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Optionally: parameterized tests support -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>ovara-lampi-siirtaja</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<configuration>
<archive>
<manifest>
<mainClass>fi.oph.opintopolku.ovara.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>true</appendAssemblyId>
</configuration>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package fi.oph.opintopolku.ovara;

import com.amazonaws.regions.Regions;
import fi.oph.opintopolku.ovara.db.DatabaseToS3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.stream.Stream;

public class App {

public static final Logger LOG = LoggerFactory.getLogger(App.class);

public static void main(String[] args) throws Exception {

Config config = new Config(
System.getProperty("POSTGRES_HOST"),
Integer.valueOf(System.getProperty("POSTGRES_PORT")),
System.getProperty("DB_USERNAME"),
System.getProperty("DB_PASSWORD"),
System.getProperty("OVARA_LAMPI_SIIRTAJA_BUCKET"),
System.getProperty("LAMPI_S3_BUCKET"),
Regions.EU_WEST_1.getName()
);

DatabaseToS3 db = new DatabaseToS3(config);

Stream.of("pub").forEach(schemaName -> {
try {
LOG.info("Haetaan scheman {} taulut", schemaName);
List<String> tableNames = db.getTableNames("pub");
LOG.info("Scheman {} taulut: ", tableNames);
} catch (Exception e) {
throw new RuntimeException(e);
}
});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fi.oph.opintopolku.ovara;

public record Config (
String postgresHost,
Integer postgresPort,
String postgresUser,
String postgresPassword,
String ovaraS3Bucket,
String lampiS3Bucket,
String awsRegion
) { }
Loading

0 comments on commit 36b7351

Please sign in to comment.