Skip to content
Open

Test2 #129

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
79 changes: 79 additions & 0 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This workflow will build and push a new container image to Amazon ECR,
# and then will deploy a new task definition to Amazon ECS, when there is a push to the "main" branch.
#
# To use this workflow, you will need to complete the following set-up steps:
#
# 1. Create an ECR repository to store your images.
# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`.
# Replace the value of the `ECR_REPOSITORY` environment variable in the workflow below with your repository's name.
# Replace the value of the `AWS_REGION` environment variable in the workflow below with your repository's region.
#
# 2. Create an ECS task definition, an ECS cluster, and an ECS service.
# For example, follow the Getting Started guide on the ECS console:
# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun
# Replace the value of the `ECS_SERVICE` environment variable in the workflow below with the name you set for the Amazon ECS service.
# Replace the value of the `ECS_CLUSTER` environment variable in the workflow below with the name you set for the cluster.
#
# 3. Store your ECS task definition as a JSON file in your repository.
# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`.
# Replace the value of the `ECS_TASK_DEFINITION` environment variable in the workflow below with the path to the JSON file.
# Replace the value of the `CONTAINER_NAME` environment variable in the workflow below with the name of the container
# in the `containerDefinitions` section of the task definition.
#
# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
# See the documentation for each action used below for the recommended IAM policies for this IAM user,
# and best practices on handling the access key credentials.

name: Deploy to Amazon ECS

on:
push:
tags:
- '*'

env:
AWS_REGION: eu-north-1 # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: 337878073417.dkr.ecr.eu-north-1.amazonaws.com/test # set this to your Amazon ECR repository name
ECS_SERVICE: test # set this to your Amazon ECS service name
ECS_CLUSTER: citibeats-sandbox # set this to your Amazon ECS cluster name

permissions:
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
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: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
IMAGE_TAG: "latest"
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Deploy again - substitute currently running tasks with tasks with the actual latest image.
id: force-deployment
run: |
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment
22 changes: 0 additions & 22 deletions CHANGELOG.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG NODE_VER="14.3.0"
# --------------------------------------
# BASE NODE
# --------------------------------------
FROM node:${NODE_VER}-alpine as BASE
FROM node:${NODE_VER}-alpine as base

ARG PORT=3000
ENV PORT=$PORT
Expand All @@ -16,7 +16,7 @@ COPY package.json package-lock.json ./
# --------------------------------------
# DEPENDENCIES
# --------------------------------------
FROM BASE as DEPENDENCIES
FROM base as dependencies

RUN npm install --only=production

Expand All @@ -31,7 +31,7 @@ RUN npm install
# TEST
# --------------------------------------
# run linters, setup and tests
FROM dependencies AS TEST
FROM dependencies AS test

COPY .eslintrc.json .
COPY /src ./src/
Expand All @@ -42,7 +42,7 @@ RUN npm run lint && npm run test
# --------------------------------------
# RELEASE
# --------------------------------------
FROM BASE as RELEASE
FROM base as release

# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ help: ## Show this help.
@echo ''
.PHONY: help

gen-readme: ## Generate README.md (using docker-verb)
gen-readme: ## Generate READMfE.md (using docker-verb)
docker run --rm -v ${PWD}:/opt/verb stefanwalther/verb
.PHONY: gen-readme

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker-test

> Sample docker image to test various scenarios with Docker.
> Sample docker image to test various scenarios with Docker

[![CircleCI](https://img.shields.io/circleci/project/github/stefanwalther/docker-test.svg)](https://circleci.com/gh/stefanwalther/docker-test/tree/master)
[![XO code style](https://img.shields.io/badge/code_style-XO--space-5ed9c7.svg)](https://github.com/sindresorhus/eslint-config-xo-space)
Expand Down Expand Up @@ -129,7 +129,7 @@ Pull requests and stars are always welcome. For bugs and feature requests, [plea
2. Work on whatever bug or feature you wish
3. Create a pull request (PR)

I cannot guarantee that I will merge all PRs but I will evaluate them all.
I cannot guarantee that I will merge all PRs but I will evaluate them all

### License
Copyright © 2020, [Stefan Walther](http://qliksite.io).
Expand Down
Empty file added a
Empty file.
Empty file added b
Empty file.
Empty file added c
Empty file.
Empty file added d
Empty file.
4 changes: 2 additions & 2 deletions src/modules/default/default.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ class Controller {
static get(req, res) {
console.log('We are here');
if (req.query.output === 'text') {
res.send('Hello World').end();
res.sendFile(path.join('/.index.html'));
} else {

res.json({text: 'Hello World'}).end();
res.sendFile(path.join('./index.html'));
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/modules/default/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Static Page</title>
<style>
body {
text-align: center;
}
</style>
</head>
<body>
<h1>Welcome to the Static Page!</h1>
<p>This is some underlying text.</p>
</body>
</html>