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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.swm
node_modules/
*.sqlite
*.terraform
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,28 @@
# 4. Login to running container (to update config (vi config/app.json):
# docker exec -ti --user root alpine_timeoff /bin/sh
# --------------------------------------------------------------------
FROM alpine:latest as dependencies

RUN apk add --no-cache \
nodejs npm

COPY package.json .
RUN npm install

FROM alpine:latest

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.docker.cmd="docker run -d -p 3000:3000 --name alpine_timeoff"

RUN apk update && apk upgrade
RUN apk add --no-cache \
git \
make \
nodejs npm \
python3 \
vim

COPY package.json .
RUN npm install

RUN adduser --system app --home /app
USER app
WORKDIR /app
COPY . /app
COPY --from=dependencies node_modules ./node_modules

CMD npm start

EXPOSE 3000
EXPOSE 3000
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@

# TimeOff.Management

Web application for managing employee absences.

<a href="https://travis-ci.org/timeoff-management/timeoff-management-application"><img align="right" src="https://travis-ci.org/timeoff-management/timeoff-management-application.svg?branch=master" alt="Build status" /></a>


# Some notes for this project

Here are some details on the solution implemented with this application:

* **Cloud provider**: AWS
* **IaC solution**: Terraform
* **Container orchestration service**: ECS
* **CI/CD Pipeline**: GitHub, AWS CodeBuild, AWS CodeDeploy and AWS CodePipeline

Here you can see a diagram describing the different services used to run this application:
![Architecture Diagram](timeoff-app.png)

As shown in the diagram, the application sits behind an AWS Application Load Balancer and is higly available thanks to the Elastic Container Service and runs on Fargate instances as containers. These containers are located under the VPC's private subnets so the actual application is protected and only reachable via the load balancer.

Every time a commit is pushed to the develop branch, a build process will start using AWS CodeBuild and this service will push the containerized image to a private ECR Repository. Once the new image is pushed, this will trigger a deployment via AWS CodeDeploy, in this case we are leveraging a canary deployment using Codedeploy.

The application is currently accesible via the following addresses (one with HTTPS support from my understanding of application requirements)
* https://timeoff-app.dereedere.link:444/login/
* http://timeoff-app.dereedere.link/login/

An /infrastructure in the repositoy's branch subfolder holds all the Terraform configuration files used. Additionally, the configuration has some rough modularization to set the tone for reusable configuration hopefully in the future, either via workspaces or module usage.

Below are some generic details about changes made to the application and the infrastructure:

*Changes*
- Removed multicontainer from Dockerfile
- Change on sqllite3 version - pined to 5.0.0
- Change on node-sass version - upgraded to "^5.0.0" due to unsupported compatibility with gyp and python3


*Recomendations*
- Pin version of source image
- Use public-ecr or private-ecr-repository to prevent rate limiting without requiring Docker Hub Authentication



## Features

**Multiple views of staff absences**
Expand Down
9 changes: 9 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "timeoff-app"
ContainerPort: 3000
18 changes: 18 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.2

phases:
install:
runtime-versions:
nodejs: 14
pre_build:
commands:
- docker login -u $dockerhub_username -p $dockerhub_password
build:
commands:
- docker build -t $ecr_repo_name:$image_tag .
post_build:
commands:
- echo Build completed on `date`
- echo Pushing image to $ecr_repo_name
- aws ecr get-login-password --region $AWS_REGION | docker login -u AWS --password-stdin $account_id.dkr.ecr.$AWS_REGION.amazonaws.com
- docker push $ecr_repo_name:$image_tag
1 change: 1 addition & 0 deletions infrastructure/global/.terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.9
22 changes: 22 additions & 0 deletions infrastructure/global/.terraform.lock.hcl

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

Loading