Skip to content

Commit

Permalink
Merge branch 'bcgov:main' into feature/WFPREV-61
Browse files Browse the repository at this point in the history
  • Loading branch information
ssylver93 authored Oct 11, 2024
2 parents 59f0daf + 9c53860 commit 149c9b0
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 35 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/mvn-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ jobs:
export MAVEN_OPTS="-Xmx3072m -XX:MaxMetaspaceSize=512m"
export NODE_OPTIONS="--max-old-space-size=4096"
mvn --settings ${{ inputs.COMPONENT_TYPE }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f ${{ inputs.COMPONENT_TYPE }}/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package

cd ${{ inputs.COMPONENT_TYPE }}/wfprev-war/src/main/angular
npm install
npm run build -- --base-href="/pub/wfprev/"
- name: Copy files to neccessary folders
run: mkdir staging && cp ${{ inputs.COMPONENT_TYPE }}/${{ inputs.COMPONENT_NAME }}/target/*.war staging

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
-DWEBADE_OAUTH2_CHECK_TOKEN_URL=${{ vars.WEBADE_OAUTH2_CHECK_TOKEN_URL }} \
-DWEBADE_OAUTH2_CHECK_AUTHORIZE_URL=${{ vars.WEBADE_OAUTH2_CHECK_TOKEN_URL }} \
-DWFPREV_DATASOURCE_URL=${{ vars.WFPREV_DATASOURCE_URL }} \
-DWFPREV_DATASOURCE_USERNAME=${{ vars.WFPREV_USERNAME }} \
-DWFPREV_DATASOURCE_USERNAME=${{ secrets.WFPREV_USERNAME }} \
-DWFPREV_DATASOURCE_PASSWORD=${{ secrets.DB_PASS }}
- name: SonarCloud Scan Action
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/terragrunt-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ jobs:
WEBADE_OAUTH2_CHECK_TOKEN_URL: ${{vars.WEBADE_OAUTH2_CHECK_TOKEN_URL}}
WEBADE_OAUTH2_CHECK_AUTHORIZE_URL: ${{vars.WEBADE_OAUTH2_CHECK_AUTHORIZE_URL}}
WFPREV_DATASOURCE_URL: ${{vars.WFPREV_DATASOURCE_URL}}
WFPREV_DATASOURCE_USERNAME: ${{vars.WFPREV_USERNAME}}
WFPREV_DATASOURCE_USERNAME: ${{secrets.WFPREV_USERNAME}}
WFPREV_DATASOURCE_PASSWORD: ${{secrets.DB_PASS}}
server_count: ${{vars.WFPREV_SERVER_INSTANCE_COUNT}}
# WFPREV UI
CLIENT_IMAGE: ${{ steps.getDigestUI.outputs.IMAGE_UI_BY_DIGEST }}
WEBADE_OAUTH2_WFPREV_UI_CLIENT_SECRET: ${{ secrets.WEBADE_OAUTH2_WFPREV_UI_CLIENT_SECRET }}
Expand Down
1 change: 1 addition & 0 deletions client/wfprev-war/src/main/angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"baseHref": "/pub/wfprev/",
"outputPath": "dist/wfprev",
"index": "src/index.html",
"main": "src/main.ts",
Expand Down
62 changes: 62 additions & 0 deletions db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# WFPrev Local PostGIS Setup

This guide will help you build a local instance of PostGIS, set up the database, and apply the model using Liquibase from the change log.

## Prerequisites

- Docker installed on your local machine.
- `Dockerfile.liquibase.local`, `main-changelog.json`, and the `scripts` folder available in your repository.

## Project Structure

- **`main-changelog.json`**: The main Liquibase changelog file, which includes the following changes:
- Creates logins using SQL scripts.
- Creates roles.
- Creates the `wfprev` schema.
- Adds required extensions.
- **`Dockerfile.liquibase.local`**: Dockerfile for running Liquibase commands.
- **`scripts` folder**: Contains the SQL scripts for various database changes as referenced in `main-changelog.json`.

## Step 1: Pull and Run PostGIS

1. **Pull the PostGIS Image**:

```bash
docker pull postgis/postgis:16-3.4

2. **Run the PostGIS Containe**:

```bash
docker run --name wfprev-postgres -e POSTGRES_USER=wfprev -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgis/postgis:16-3.4
## Step 2: Find the IP Address
1. **Get the Container ID:** :
docker ps
2. **Inspect the Container for IP Address:** :
docker inspect <container_id>
## Step 3: Set Up and Run Liquibase
1. **Build the Liquibase Docker Image** :
Create a Dockerfile.liquibase.local with the following content:
FROM liquibase/liquibase
COPY ./scripts ./scripts
COPY ./main-changelog*.json .
COPY ./liquibase.properties .
ENTRYPOINT [ "sh", "-c", "liquibase $COMMAND $TARGET_LIQUIBASE_TAG --changelog-file=$CHANGELOG_FILE -Dschemaname=$SCHEMA_NAME" ]
Build the Liquibase Docker image:
docker build -t liquibase -f Dockerfile.liquibase.local .
2. ** Run Liquibase Update:**:
docker run --rm liquibase \
--url=jdbc:postgresql://<your_postgis_ip>:5432/wfprev \
--changelog-file=main-changelog.json \
--username=wfprev \
--password=password \
update
28 changes: 0 additions & 28 deletions db/README.txt

This file was deleted.

22 changes: 22 additions & 0 deletions server/wfprev-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@
<scope>test</scope>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>

<!-- Common Software Framework -->
<dependency>
<groupId>ca.bc.gov.nrs.wfone.common</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.util.Date;
import java.util.UUID;

import org.apache.http.HttpStatus;
import org.springframework.hateoas.CollectionModel;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -29,7 +29,6 @@
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
Expand All @@ -53,7 +52,7 @@

@RestController
@Slf4j
@RequestMapping(value="wfprev")
@RequestMapping(value="/wfprev")
public class ExampleController extends CommonController {
private ExampleService exampleService;

Expand Down
19 changes: 19 additions & 0 deletions server/wfprev-api/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console" />
</Root>
<Logger name="ca.bc.gov.nrs.wfone" level="INFO">
<AppenderRef ref="Console" />
</Logger>
<Logger name="javax.net.debug" level="ERROR">
<AppenderRef ref="Console" />
</Logger>
</Loggers>
</Configuration>
26 changes: 26 additions & 0 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
data "aws_ami" "amzn-linux-2023-ami" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["al2023-ami-2023.*-x86_64"]
}
}

resource "aws_instance" "jumphost" {
ami = data.aws_ami.amzn-linux-2023-ami.id
instance_type = "t2.micro"
subnet_id = module.network.aws_subnet_ids.app.ids[0]
vpc_security_group_ids = [data.aws_security_group.app.id, aws_security_group.jumphost.id]
ebs_optimized = false
ebs_block_device {
device_name = "/dev/xvda"
encrypted = true
volume_size = 8
}

tags = {
Name = "jumphost-${var.TARGET_ENV}"
}
}
19 changes: 19 additions & 0 deletions terraform/security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@ resource "aws_security_group" "wfprev_tomcat_access" {
to_port = var.WFPREV_API_PORT
cidr_blocks = ["0.0.0.0/0"]
}
}

resource "aws_security_group" "jumphost" {
name = "wfprev-jumphost-access"
description = "Allow access to jumphost via ssm"
vpc_id = module.network.aws_vpc.id
ingress {
protocol = "tcp"
from_port = 3389
to_port = 3389
security_groups = [data.aws_security_group.web.id]
}

ingress {
protocol = "tcp"
from_port = 3389
to_port = 3389
security_groups = [data.aws_security_group.app.id]
}
}
1 change: 1 addition & 0 deletions terraform/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ WEBADE_OAUTH2_CHECK_AUTHORIZE_URL = "${get_env("WEBADE_OAUTH2_CHECK_AUTHORIZE_UR
WFPREV_DATASOURCE_URL = "${get_env("WFPREV_DATASOURCE_URL")}"
WFPREV_DATASOURCE_USERNAME = "${get_env("WFPREV_DATASOURCE_USERNAME")}"
WFPREV_DATASOURCE_PASSWORD = "${get_env("WFPREV_DATASOURCE_PASSWORD")}"
server_count = "${get_env("server_count")}"
TARGET_AWS_ACCOUNT_ID = "${get_env("TARGET_AWS_ACCOUNT_ID")}"
Expand Down

0 comments on commit 149c9b0

Please sign in to comment.