Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
62d569b
feat: TT-509 Use terraform to provision ui infraestructure
jatobrun Mar 8, 2022
72cf8f7
feat: TT-580 Missing placeholders (#820)
alejandra-ponce Mar 10, 2022
a458f98
chore(release): 1.66.0 [skip ci]nn
semantic-release-bot Mar 10, 2022
bf8977e
TT-xx: Fix make publish tasks (#822)
faustocv Mar 10, 2022
3fe4e5e
fix: TT-509 expose port 8080 in docker images
jatobrun Mar 10, 2022
6cc64e6
fix: TT-509 change app to port 80
jatobrun Mar 14, 2022
4ee7c37
feat: TT-578 improve the style of the form element (#823)
iHackN3WTON Mar 14, 2022
482bfb1
chore(release): 1.67.0 [skip ci]nn
semantic-release-bot Mar 14, 2022
3e614fd
TT-582 Improve the summary section of the time-clock page and the clo…
LuisMS7 Mar 15, 2022
483cf6a
fix: TT-509 including empty line in all files
jatobrun Mar 15, 2022
a4b8426
fix: TT-509 Change the dockerfile to use root user and not app user
jatobrun Mar 16, 2022
429c008
feat: TT-576 Improve grids visual presentation and function (#826)
iHackN3WTON Mar 16, 2022
24d7f40
chore(release): 1.68.0 [skip ci]nn
semantic-release-bot Mar 16, 2022
3bee7e3
feat: TT-577 get profile pic from Google account (#825)
kjduy Mar 16, 2022
4c48be4
chore(release): 1.69.0 [skip ci]nn
semantic-release-bot Mar 16, 2022
98d092c
Revert "feat: TT-577 get profile pic from Google account (#825)" (#829)
alejandra-ponce Mar 17, 2022
454b7f9
chore(release): 1.69.1 [skip ci]nn
semantic-release-bot Mar 17, 2022
ac17c44
style: TT-579 Buttons and searchbar adjusted to the app style (#827)
MarcoAguirre Mar 17, 2022
0b48625
fix: TT-590 unable to pass ci test (#831)
alejandra-ponce Mar 17, 2022
da50b7a
chore(release): 1.69.2 [skip ci]nn
semantic-release-bot Mar 17, 2022
82e6dea
Tt 582 improve the summary section of the time clock page QA (#830)
codigodehoy Mar 17, 2022
97b6435
fix: TT-509 pr comments
jatobrun Mar 18, 2022
8993fbc
fix: TT-509 using remote state to load variables
jatobrun Mar 18, 2022
9c33cee
Update variables.tf
jatobrun Mar 21, 2022
33096b5
delete prefix docker
jatobrun Mar 21, 2022
37e64ee
delete prefix docker in locals block
jatobrun Mar 21, 2022
e0dc5f7
fix: Update the values of the terraform state output
jatobrun Mar 21, 2022
df9071c
fix: resolve package-lock conflicts
FreddyJR1995 Mar 22, 2022
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ Thumbs.db

#ENV VARIABLES
.env

# Terraform files
**/.terraform**
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.pid

USER ${USERNAME}

EXPOSE 4200
# FIXME: Actually if we can deploy to azure in port 80 we need a root user
# Maybe we can refactor this dockerfile to use root user directly this is not a good approach y
# security terms. It's a good practice to have rootless in containers so for this
# we can to refactor this dockerfile and the terraform module to deploy in other ports because
# Ports below 1024 needs root permisions.

# USER ${USERNAME}

EXPOSE 80
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ logs: ## Show logs of timetracker_ui.

.PHONY: stop
stop: ## Stop container timetracker_ui.
docker-compose stop
docker-compose stop

.PHONY: restart
restart: ## Restart container timetracker_ui.
docker-compose stop
docker-compose stop
docker-compose up -d

.PHONY: remove
Expand All @@ -44,17 +44,17 @@ test: ## Run all tests on docker container timetracker_ui.
docker exec -it timetracker_ui bash -c "npm run test"

.PHONY: publish
publish: ## Publish the container image timetracker_ui.
docker tag timetracker_ui:latest $(registry_url)/timetracker_ui:latest
docker push $(registry_url)/timetracker_ui:latest
publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the stage azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
docker tag timetracker_ui:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)

.PHONY: build_prod
build_prod: ## Create docker image with dependencies needed for production.
docker build --target production -t timetracker_ui_prod -f Dockerfile .

.PHONY: run_prod
run_prod: ## Execute timetracker_ui_prod docker container.
docker run -d -p 4200:4200 --name timetracker_ui_prod timetracker_ui_prod
docker run -d -p 4200:4200 --name timetracker_ui_prod timetracker_ui_prod

.PHONY: stop_prod
stop_prod: ## Stop container timetracker_ui_prod.
Expand All @@ -66,10 +66,27 @@ remove_prod: ## Delete container timetracker_ui_prod.
docker rm timetracker_ui_prod

.PHONY: publish_prod
publish_prod: ## Publish the container image timetracker_ui_prod.
docker tag timetracker_ui_prod:latest $(registry_url)/timetracker_ui_prod:latest
docker push $(registry_url)/timetracker_ui_prod:latest
publish_prod: require-acr-arg require-image_tag-arg ## Upload a docker image to the prod azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
docker tag timetracker_ui_prod:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)

.PHONY: login
login: ## Login in respository of docker images.
az acr login --name $(container_registry)

.PHONY: release
release: require-VERSION-arg require-COMMENT-arg ## Creates an pushes a new tag.
git tag -a ${VERSION} -m "${COMMENT}"
git push origin ${VERSION}

require-%-arg:
@if [ -z ${${*}} ]; then \
echo "ERROR: [$*] argument is required, e.g. $*=<value>"; \
exit 1; \
fi

require-%-tool:
@if [ "$(shell command -v ${*} 2> /dev/null)" = "" ]; then \
echo "ERROR: [$*] not found"; \
exit 1; \
fi
59 changes: 59 additions & 0 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
terraform {
required_version = "~> 1.1.2"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.90"
}
}

backend "azurerm" {
resource_group_name = "ioet-infra-tf-state"
storage_account_name = "timetrackertfstate"
container_name = "time-tracker-tf-state"
key = "time-tracker-ui.tfstate"
}

}

provider "azurerm" {
features {}
skip_provider_registration = true
}

data "terraform_remote_state" "service" {
backend = "azurerm"
workspace = terraform.workspace
config = {
resource_group_name = "ioet-infra-tf-state"
storage_account_name = "timetrackertfstate"
container_name = "time-tracker-tf-state"
key = "this.tfstate"
}
}

locals {
common_name = "time-tracker-ui"
environment = terraform.workspace
service_name = "${local.common_name}-${local.environment}"
create_app_service_plan = true
service_plan_kind = "Linux"
image_name = "timetracker_ui"
}

module "ui" {
source = "[email protected]:ioet/infra-terraform-modules.git//azure-app-service?ref=tags/v0.0.5"
app_service_name = local.service_name
create_app_service_plan = local.create_app_service_plan
docker_image_name = "${local.image_name}:${var.image_tag}"
docker_image_namespace = data.terraform_remote_state.service.outputs.container_registry_login_server
docker_registry_password = data.terraform_remote_state.service.outputs.container_registry_admin_password
docker_registry_url = data.terraform_remote_state.service.outputs.container_registry_login_server
docker_registry_username = data.terraform_remote_state.service.outputs.container_registry_admin_username
location = data.terraform_remote_state.service.outputs.container_registry_location
resource_group_name = data.terraform_remote_state.service.outputs.resource_group_name
service_plan_kind = local.service_plan_kind
service_plan_name = local.service_name
service_plan_size = var.service_plan_size
service_plan_tier = var.service_plan_tier
}
2 changes: 2 additions & 0 deletions infrastructure/prod.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_plan_size = "S1"
service_plan_tier = "Standard"
2 changes: 2 additions & 0 deletions infrastructure/stage.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_plan_size = "S1"
service_plan_tier = "Standard"
17 changes: 17 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "image_tag" {
type = string
description = "Specifies the docker image tag that is stored in a private container registry like ACR (Azure Container Registry)."
sensitive = true
}

variable "service_plan_size" {
default = "S1"
type = string
description = "Specifies the size of the service plan. This variable format is: Tier (letter) + Size (number). Size could be: 1 = Small (1 Core 1.75GB RAM), 2 = Medium (2 Core 3.5 GB RAM), 3 = Large (4 Core 7GB RAM)"
}

variable "service_plan_tier" {
default = "Standard"
type = string
description = "Specifies the tier of the service plan. Tier is the pricing plan of the service plan resource."
}
4 changes: 2 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 4200;
listen 80;

root /usr/share/nginx/html;
index index.html;
Expand All @@ -9,4 +9,4 @@ server {
location / {
try_files $uri /index.html;
}
}
}
Loading