Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/cd-tik-stock-aws-ecs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Introduction:
#
# This workflow is responsible for both creating and pushing the container image of the generated service to
# Amazon Elastic Container Registry (ECR), aswell as rendering and deploying an task definition to an Amazon
# Elastic Container Service (ECS) cluster. Lastly the execution of a task definition requires as IAM role which
# can be consumed.

name: tik-stock-deploy-to-aws-ecs
concurrency: ${{ github.ref }}

on:
workflow_dispatch: {}
pull_request:
types: [closed]

env:
AWS_REGION: eu-west-1
ECR_REPOSITORY: repository-name
ECS_SERVICE: tik-stock
ECS_CLUSTER: development-cluster
ECS_TASK_DEFINITION: .github/workflows/configuration/cd-tik-stock-aws-ecs.json
CONTAINER_NAME: tik-stock

jobs:
package:
name: deploy
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: login to amazon ecr
id: registry
uses: aws-actions/amazon-ecr-login@v2

- name: build, tag and push image
id: image
env:
ECR_REGISTRY: ${{ steps.registry.outputs.registry }}
IMAGE_TAG: ${{github.sha}}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG server
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

# https://github.com/aws-actions/amazon-ecs-render-task-definition
- name: render amazon ecs task definition
id: task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.image.outputs.image }}

# https://github.com/aws-actions/amazon-ecs-deploy-task-definition
- name: deploy amazon ecs task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-definition.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: false
71 changes: 71 additions & 0 deletions .github/workflows/ci-tik-stock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: continuous integration - tik-stock

concurrency:
group: tik-stock
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches: ["*"]
paths: ["server"]

env:
REGISTRY: ghcr.io

jobs:
continuous-integration:
name: continuous integration
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: checkout
uses: actions/checkout@v3

- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: install dependencies
run: npm install
working-directory: server

- name: build
run: npm run build
working-directory: server

- name: test
run: npm test
working-directory: server

- name: docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/victorcampelo/tik-stock
flavor: latest=true
tags: |
type=sha,prefix=sha-
type=ref,event=branch
type=ref,event=pr,prefix=pr-
type=ref,event=tag,prefix=tag-
type=raw,value=${{ github.run_id }},prefix=gh-

- name: login to image repostiory
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: victorcampelo
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and push
uses: docker/build-push-action@v3
with:
context: server
file: server/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
58 changes: 58 additions & 0 deletions .github/workflows/configuration/cd-tik-stock-aws-ecs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"family": "tik-stock",
"containerDefinitions": [
{
"name": "tik-stock",
"image": "012345678901.dkr.ecr.eu-west-1.amazonaws.com/repository-name:latest",
"essential": true,
"portMappings": [
{
"name": "tik-stock-3000-tcp",
"containerPort": 3000,
"hostPort": 3000,
"protocol": "tcp"
}
],
"secrets": [
{
"name": "BCRYPT_SALT",
"valueFrom": "arn:aws:secretsmanager:eu-west-1:012345678901:secret:secret-name:BCRYPT_SALT::"
},
{
"name": "JWT_EXPIRATION",
"valueFrom": "arn:aws:secretsmanager:eu-west-1:012345678901:secret:secret-name:JWT_EXPIRATION::"
},
{
"name": "JWT_SECRET_KEY",
"valueFrom": "arn:aws:secretsmanager:eu-west-1:012345678901:secret:secret-name:JWT_SECRET_KEY::"
},
{
"name": "DB_URL",
"valueFrom": "arn:aws:secretsmanager:eu-west-1:012345678901:secret:secret-name:DB_URL::"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/tik-stock",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "ecs"
}
},
"mountPoints": [],
"volumesFrom": []
}
],
"executionRoleArn": "arn:aws:iam::012345678901:role/task-execution-role-name",
"networkMode": "awsvpc",
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "2048",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
}
}
12 changes: 12 additions & 0 deletions admin-ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Add further files to ignore here as needed

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
10 changes: 3 additions & 7 deletions admin-ui/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended"
"plugin:react/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"react"
],
"plugins": ["@typescript-eslint", "react"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {}

}
}
17 changes: 17 additions & 0 deletions admin-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add further files to ignore here as needed

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/dist

#Server Specific
prisma/migrations/
package-lock.json
1 change: 1 addition & 0 deletions admin-ui/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion admin-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN chown -R nginx:nginx /var/run/nginx.pid \
USER nginx

# expose a specific port on the docker container
ENV PORT=80
ENV PORT=3001
EXPOSE ${PORT}

# start the server using the previously build application
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<p align="right">
<a href="https://amplication.com" target="_blank">
<img alt="amplication-logo" height="70" alt="Amplication Logo" src="https://amplication.com/images/amplication-logo-purple.svg"/>
<img alt="amplication-logo" height="70" alt="Amplication Logo" src="https://amplication.com/images/logo.svg"/>
</a>
</p>

# Introduction

This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, premissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/).
This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, permissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/).


<p align="center">
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/configuration/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server_tokens off;

server {
listen 8080;
listen 3001;
server_name localhost;
location / {
root /usr/share/nginx/html;
Expand Down
12 changes: 6 additions & 6 deletions admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"package:container": "docker build .",
"format": "prettier --write .",
"lint": "eslint './src/**/*.{ts, tsx}'",
"lint:fix": "eslint --fix './src/**/*.{ts, tsx}'"
"lint:fix": "eslint --fix './src/**/*.{ts, tsx}'",
"format": "prettier --write ."
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -57,12 +57,12 @@
"@types/node": "12.20.16",
"@types/react": "16.14.11",
"@types/react-dom": "17.0.0",
"type-fest": "0.13.1",
"typescript": "4.3.5",
"prettier": "^2.8.0",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"eslint": "^7.0.0",
"eslint-plugin-react": "^7.33.1"
"eslint-plugin-react": "^7.33.1",
"prettier": "^2.8.0",
"type-fest": "0.13.1",
"typescript": "4.3.5"
}
}
7 changes: 3 additions & 4 deletions admin-ui/src/api/user/User.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Strategy } from "../strategy/Strategy";
import { JsonValue } from "type-fest";
import { Strategy } from "../strategy/Strategy";

export type User = {
createdAt: Date;
email: string;
firstname: string | null;
id: number;
lastname: string | null;
role?: "ADMIN" | "USER";
roles: JsonValue;
strategy?: Array<Strategy>;
updatedAt: Date;
username: string;
roles: JsonValue;
username: string | null;
};
7 changes: 3 additions & 4 deletions admin-ui/src/api/user/UserCreateInput.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { StrategyCreateNestedManyWithoutUsersInput } from "./StrategyCreateNestedManyWithoutUsersInput";
import { InputJsonValue } from "../../types";
import { StrategyCreateNestedManyWithoutUsersInput } from "./StrategyCreateNestedManyWithoutUsersInput";

export type UserCreateInput = {
email: string;
firstname?: string | null;
lastname?: string | null;
role: "ADMIN" | "USER";
strategy?: StrategyCreateNestedManyWithoutUsersInput;
username: string;
password: string;
roles: InputJsonValue;
strategy?: StrategyCreateNestedManyWithoutUsersInput;
username?: string | null;
};
5 changes: 2 additions & 3 deletions admin-ui/src/api/user/UserOrderByInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ export type UserOrderByInput = {
firstname?: SortOrder;
id?: SortOrder;
lastname?: SortOrder;
role?: SortOrder;
updatedAt?: SortOrder;
username?: SortOrder;
password?: SortOrder;
roles?: SortOrder;
updatedAt?: SortOrder;
username?: SortOrder;
};
7 changes: 3 additions & 4 deletions admin-ui/src/api/user/UserUpdateInput.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { StrategyUpdateManyWithoutUsersInput } from "./StrategyUpdateManyWithoutUsersInput";
import { InputJsonValue } from "../../types";
import { StrategyUpdateManyWithoutUsersInput } from "./StrategyUpdateManyWithoutUsersInput";

export type UserUpdateInput = {
email?: string;
firstname?: string | null;
lastname?: string | null;
role?: "ADMIN" | "USER";
strategy?: StrategyUpdateManyWithoutUsersInput;
username?: string;
password?: string;
roles?: InputJsonValue;
strategy?: StrategyUpdateManyWithoutUsersInput;
username?: string | null;
};
2 changes: 1 addition & 1 deletion admin-ui/src/api/user/UserWhereInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type UserWhereInput = {
firstname?: StringNullableFilter;
id?: IntFilter;
lastname?: StringNullableFilter;
role?: "ADMIN" | "USER";
strategy?: StrategyListRelationFilter;
updatedAt?: DateTimeFilter;
username?: StringNullableFilter;
};
Loading