Skip to content

Commit

Permalink
[EC-125] Add Container App infrastructure (#175)
Browse files Browse the repository at this point in the history
Co-authored-by: manuraf <[email protected]>
  • Loading branch information
Krusty93 and manuraf authored Mar 12, 2024
1 parent 2465078 commit 68b2328
Show file tree
Hide file tree
Showing 33 changed files with 825 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr_ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
jobs:

code_review:
uses: pagopa/selfcare-commons/.github/workflows/call_code_review_spring.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_code_review_spring.yml@main
name: 'Code Review'
secrets: inherit
if: github.base_ref == 'main' && github.event_name == 'pull_request'
Expand All @@ -33,5 +33,5 @@ jobs:
sonar_key: 'pagopa_selfcare-ms-party-registry-proxy'

docker_build:
uses: pagopa/selfcare-commons/.github/workflows/call_code_review_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_code_review_docker.yml@main
name: 'Docker'
31 changes: 21 additions & 10 deletions .github/workflows/release_ms.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: Release ms-party-registry-proxy
name: Release - ms-party-registry-proxy

on:
workflow_dispatch:
inputs:
env:
type: choice
description: Environment
options:
- dev
- uat
- prod

push:
branches:
Expand All @@ -19,28 +27,31 @@ on:
jobs:

release_dev:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[Dev] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/') != true
if: ${{ (startsWith(github.ref_name, 'releases/') != true && inputs.env == null) || inputs.env == 'dev' }}
secrets: inherit
with:
environment: dev
dir: 'infra'
tf_environment: dev
dir: 'infra/container_apps'

release_uat:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[UAT] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/')
if: ${{ (startsWith(github.ref_name, 'releases/') == true && inputs.env == null) || inputs.env == 'uat' }}
secrets: inherit
with:
environment: uat
dir: 'infra'
tf_environment: uat
dir: 'infra/container_apps'

release_prod:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[Prod] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/')
if: ${{ inputs.env == 'prod' }}
secrets: inherit
with:
environment: prod
dir: 'infra'
tf_environment: prod
dir: 'infra/container_apps'
28 changes: 18 additions & 10 deletions .github/workflows/release_ms_pnpg.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: Release PNPG ms-party-registry-proxy
name: Release - PNPG ms-party-registry-proxy

on:
workflow_dispatch:
inputs:
env:
type: choice
description: Environment
options:
- dev
- uat
- prod

push:
branches:
Expand All @@ -19,31 +27,31 @@ on:
jobs:

release_dev:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[Dev] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/') != true
if: ${{ (startsWith(github.ref_name, 'releases/') != true && inputs.env == null) || inputs.env == 'dev' }}
secrets: inherit
with:
environment: dev
tf_environment: dev-pnpg
dir: 'infra'
dir: 'infra/container_apps'

release_uat:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[UAT] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/')
if: ${{ (startsWith(github.ref_name, 'releases/') == true && inputs.env == null) || inputs.env == 'uat' }}
secrets: inherit
with:
environment: uat
tf_environment: uat-pnpg
dir: 'infra'
dir: 'infra/container_apps'

release_prod:
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@EC-149-template-git-hub-workflows
uses: pagopa/selfcare-commons/.github/workflows/call_release_docker.yml@main
name: '[Prod] PartyRegistryProxy ms Release'
if: startsWith(github.ref_name, 'releases/')
if: ${{ inputs.env == 'prod' }}
secrets: inherit
with:
environment: prod
tf_environment: prod-pnpg
dir: 'infra'
dir: 'infra/container_apps'
8 changes: 6 additions & 2 deletions Dockerfile.new
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ WORKDIR /app

COPY --from=builder ./target/*.jar ./app.jar

ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.1.1/applicationinsights-agent-3.1.1.jar /applicationinsights-agent.jar
ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.2.11/applicationinsights-agent-3.2.11.jar ./applicationinsights-agent.jar
RUN chmod 755 ./applicationinsights-agent.jar

EXPOSE 8080
RUN chown -R 1001:1001 /app
RUN chmod 755 /app
USER 1001

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public List<InsuranceCompany> getInsurances() {
} catch (Exception e) {
log.error("Impossible to acquire data for IVASS. Error: {}", e.getMessage(), e);
}
log.debug("getInsurances result = {}", companies);
//log.debug("getInsurances result = {}", companies);
log.trace("getInsurances end");
return companies
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Optional<InputStream> getFile(String fileName) {
}

private Optional<InputStream> connectAndRetrieveFile(ChannelSftp channelSftp, String fileName) throws JSchException, SftpException, IOException {
channelSftp.connect();
channelSftp.connect(30000);
InputStream inputStream = channelSftp.get(fileName);
InputStream finalInputStream = new ByteArrayInputStream(inputStream.readAllBytes());
return Optional.of(finalInputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DirectoryReader create() {
currentReader = Optional.ofNullable(DirectoryReader.openIfChanged(currentReader))
.orElse(currentReader);
}
log.debug("create result = {}", currentReader);
//log.debug("create result = {}", currentReader);
log.trace("create end");
return currentReader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IndexWriterFactoryTemplate(Directory directory, Analyzer analyzer) {
public IndexWriter create() {
log.trace("create start");
final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(analyzer));
log.debug("create result = {}", indexWriter);
//log.debug("create result = {}", indexWriter);
log.trace("create end");
return indexWriter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public IndexWriterServiceTemplate(IndexWriterFactory indexWriterFactory, Functio
@Override
public void adds(List<? extends T> items) {
log.trace("adds start");
log.debug("adds items = {}", items);
log.debug("adds items = {}", items.size());
final IndexWriter indexWriter = indexWriterFactory.create();
try (indexWriter) {
for (T item : items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public List<I> getInstitutions() {
}

//TODO: scartare i record che non soddisfano determinati requisiti?
log.debug("getInstitutions result = {}", institutions);
//log.debug("getInstitutions result = {}", institutions);
log.trace("getInstitutions end");
return institutions;
}
Expand All @@ -61,7 +61,7 @@ public List<C> getCategories() {
}

//TODO: scartare i record che non soddisfano determinati requisiti?
log.debug("getCategories result = {}", categories);
//log.debug("getCategories result = {}", categories);
log.trace("getCategories end");
return categories;
}
Expand All @@ -83,7 +83,7 @@ public List<A> getAOOs() {
}

//TODO: scartare i record che non soddisfano determinati requisiti?
log.debug("getAOOs result = {}", aoos);
//log.debug("getAOOs result = {}", aoos);
log.trace("getAOOs end");
return aoos;
}
Expand All @@ -105,7 +105,7 @@ public List<U> getUOs() {
}

//TODO: scartare i record che non soddisfano determinati requisiti?
log.debug("getUOs result = {}", uos);
//log.debug("getUOs result = {}", uos);
log.trace("getUOs end");
return uos;
}
Expand Down
48 changes: 48 additions & 0 deletions infra/container_apps/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions infra/container_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Container App

Deploy container on a Container App instance.

<!-- markdownlint-disable -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.0 |

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_container_app_dashboard_backend"></a> [container\_app\_dashboard\_backend](#module\_container\_app\_dashboard\_backend) | github.com/pagopa/selfcare-commons//infra/terraform-modules/container_app_microservice | main |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_app_settings"></a> [app\_settings](#input\_app\_settings) | n/a | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | n/a | yes |
| <a name="input_container_app"></a> [container\_app](#input\_container\_app) | Container App configuration | <pre>object({<br> min_replicas = number<br> max_replicas = number<br><br> scale_rules = list(object({<br> name = string<br> custom = object({<br> metadata = map(string)<br> type = string<br> })<br> }))<br><br> cpu = number<br> memory = string<br> })</pre> | n/a | yes |
| <a name="input_env_short"></a> [env\_short](#input\_env\_short) | Environment short name | `string` | n/a | yes |
| <a name="input_image_tag"></a> [image\_tag](#input\_image\_tag) | Image tag to use for the container | `string` | `"latest"` | no |
| <a name="input_is_pnpg"></a> [is\_pnpg](#input\_is\_pnpg) | (Optional) True if you want to apply changes to PNPG environment | `bool` | `false` | no |
| <a name="input_secrets_names"></a> [secrets\_names](#input\_secrets\_names) | KeyVault secrets to get values from | `map(string)` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(any)` | n/a | yes |

## Outputs

No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1 change: 1 addition & 0 deletions infra/container_apps/env/dev-pnpg/backend.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subscription=DEV-SelfCare
4 changes: 4 additions & 0 deletions infra/container_apps/env/dev-pnpg/backend.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource_group_name = "terraform-state-rg"
storage_account_name = "tfappdevselfcare"
container_name = "terraform-state"
key = "selfcare-pnpg-party-registry-proxy.container_app.tfstate"
Loading

0 comments on commit 68b2328

Please sign in to comment.