Skip to content

Commit

Permalink
Merge pull request #254 from dgrebb/release/2.1.1
Browse files Browse the repository at this point in the history
Release/2.1.1
  • Loading branch information
dgrebb authored Jun 19, 2023
2 parents 4c3254b + 3e37211 commit 484413e
Show file tree
Hide file tree
Showing 26 changed files with 204 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .cz.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"commitizen": {
"name": "cz_conventional_commits",
"version": "2.0.0",
"version": "2.1.1",
"tag_format": "$major.$minor.$patch$prerelease",
"version_type": "semver",
"bump_message": "release $current_version \u2192 $new_version"
Expand Down
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature
about: New Features
title: "[FEAT] - "
labels: enhancement
labels: feature, enhancement
assignees: dgrebb

---
Expand All @@ -13,7 +13,7 @@ assignees: dgrebb

# Implementation

1.
- [ ]

# Testing

Expand All @@ -24,3 +24,5 @@ assignees: dgrebb


# Supplementary

-
16 changes: 7 additions & 9 deletions .github/workflows/build-deploy-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ jobs:
name: ${{ github.ref == 'refs/heads/main' && 'prd' || 'stg' }}

steps:
- name: (Optional) Local Docker Package Install
if: ${{ env.ACT }}
run: |
apt-get update
apt-get install -y wget curl unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install

- name: Add Masks
run: |
Expand All @@ -46,6 +38,12 @@ jobs:
repository: dgrebb/dgrebb.com
ref: ${{ secrets.DEPLOYMENT_BRANCH }}
token: ${{ github.token }}
fetch-depth: 0

- name: Extract Branch Name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand All @@ -72,7 +70,7 @@ jobs:
run: bash _ci/build.sh

- name: Robots
if: ${{ github.ref == 'main' }}
if: ${{ steps.extract_branch.outputs.branch }} == 'main'
run: |
sed -i 's/^Disallow\: \/$/Allow\: \//' front/build/robots.txt
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

All notable changes to this project will be documented in this file.

## [2.1.1] - 2023-06-19

### 🐛 Bug Fixes

- ***(ci)*** Updates gh workflow with working branch conditional

## [2.1.0] - 2023-06-19

### 💡 Features

- ***(front)*** Adds Link renderer to include target/rel attrs for external links

### ♻️ Refactor

- ***(docker)*** Refactors dockerfile for better caching
- ***(terraform)*** Removes global tags to prevent environment resource conflicts

### 👷 Build

- ***(front)*** Comments frontend service out
- ***(front/back)*** Runs compression on and adds optimized images
- ***(project)*** Updates feature template
- ***(strapi)*** Removes example webpack config
- ***(utils)*** Updates utils for docker changes

### 💚 Continuous Integration

- ***(project)*** Removes local package install step, replaced by custom act image
- ***(project)*** Adds custom `act` image for local testing

## [2.0.0] - 2023-06-18

### 💡 Features
Expand Down
38 changes: 19 additions & 19 deletions _docker/_docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ services:
ports:
- 1337:1337

front:
platform: linux/amd64
image: ${WWW_DOMAIN}
environment:
- API_URL=${API_URL}
- API_KEY=${API_KEY}
build:
context: ../front
dockerfile: ../_docker/front.Dockerfile
args:
- API_URL=${API_URL}
- API_KEY=${API_KEY}
restart: unless-stopped
ports:
- 3000:3000
links:
- "back:back"
depends_on:
- back
# front:
# platform: linux/amd64
# image: ${WWW_DOMAIN}
# environment:
# - API_URL=${API_URL}
# - API_KEY=${API_KEY}
# build:
# context: ../front
# dockerfile: ../_docker/front.Dockerfile
# args:
# - API_URL=${API_URL}
# - API_KEY=${API_KEY}
# restart: unless-stopped
# ports:
# - 3000:3000
# links:
# - "back:back"
# depends_on:
# - back
8 changes: 8 additions & 0 deletions _docker/act.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM catthehacker/ubuntu:act-latest
RUN apt-get update \
&& apt-get install -y wget unzip \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install

CMD /bin/sh
14 changes: 11 additions & 3 deletions _docker/back.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
FROM node:18-alpine
# -------- Base Node -------- #
FROM node:18-alpine AS base
# Installing libvips-dev for sharp Compatibility
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev

# -------- Dependencies -------- #
FROM base AS dependencies
COPY package*.json /tmp
RUN cd /tmp && npm ci
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/

# -------- Release -------- #
FROM base AS release
RUN mkdir -p /opt/app
COPY --from=dependencies /tmp /opt/app/
WORKDIR /opt/app
COPY ./ .
ENV PATH /opt/app/node_modules/.bin:$PATH
RUN strapi build

# HEALTHCHECK
# -------- Healthcheck -------- #
HEALTHCHECK --interval=30s --timeout=60s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:1337/_health || exit 1

# -------- Run -------- #
EXPOSE 1337
CMD strapi start
8 changes: 0 additions & 8 deletions _tf/prd/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ provider "aws" {
region = var.region
access_key = var.aws_access_key
secret_key = var.aws_secret_key
default_tags {
tags = {
Owner = "cms@dgrebb.com"
Property = var.dashed_cmsdomain
Environment = "production"
Cost_Center = "self"
}
}
}

terraform {
Expand Down
8 changes: 0 additions & 8 deletions _tf/stg/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ provider "aws" {
region = var.region
access_key = var.aws_access_key
secret_key = var.aws_secret_key
default_tags {
tags = {
Owner = "cms@dgrebb.com"
Property = "stg-${var.dashed_cmsdomain}"
Environment = "staging"
Cost_Center = "self"
}
}
}

terraform {
Expand Down
4 changes: 3 additions & 1 deletion _utils/_scripts/act.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
printDgErr "Argument needed to specify job."
fi

act -P ubuntu-latest=catthehacker/ubuntu:act-latest \
act --pull=false -P ubuntu-latest=github-actions-test:latest \
-s GITHUB_TOKEN=$(pass dg/github/pat) \
-s DEPLOYMENT_BRANCH=develop \
-s PUBLIC_ENV=staging \
Expand All @@ -29,5 +29,7 @@ act -P ubuntu-latest=catthehacker/ubuntu:act-latest \
-s AWS_REGION=$(pass dg/aws/region) \
-s AWS_S3_BUCKET=$(pass dg/www/${1}/bucket) \
-s DISTRIBUTION=$(pass dg/aws/${1}/distribution) \
-s AWS_ECR_ROLE=$(pass dg/aws/ecr_role) \
-s AWS_ECR_REPOSITORY=$(pass dg/cms/${1}/domain) \
--container-architecture linux/amd64 \
$action
8 changes: 4 additions & 4 deletions _utils/_scripts/cms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ while test "$1" != --; do
d | dev)
setBackEnv ld
cdcms && \
trap 'printf "\n"; shredBackEnv ; printDgMsg "Done!" ; exit 0' SIGINT; \
trap 'printf "\n"; shred ; printDgMsg "Done!" ; exit 0' SIGINT; \
npm run develop
break
;;
ad | admin-dev)
setBackEnv ld
cdcms && \
trap 'printf "\n"; shredBackEnv ; printDgMsg "Done!" ; exit 0' SIGINT; \
trap 'printf "\n"; shred ; printDgMsg "Done!" ; exit 0' SIGINT; \
npm run develop -- --watch-admin
break
;;
ds | dev-stage)
setBackEnv ls
cdcms && \
trap 'printf "\n"; shredBackEnv ; printDgMsg "Done!" ; exit 0' SIGINT; \
trap 'printf "\n"; shred ; printDgMsg "Done!" ; exit 0' SIGINT; \
npm run develop -- --watch-admin
break
;;
Expand All @@ -45,4 +45,4 @@ while test "$1" != --; do
;;
esac
done
shredBackEnv
shred
71 changes: 13 additions & 58 deletions _utils/_scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,28 @@ if [ $# -eq 0 ]; then
printDgErr "Missing args!"
else
while test "$1" != --; do
setBackEnv $2
setFrontEnv $2
img $2
fimg $2
if [ "$1" != "ba" ]; then
setBackEnv $2
setDockerEnv $2
img $2
fi
case $1 in
b | build)
b | build | bb | build-back)
cd $directory/../_docker
printDgMsg "Building ${2}..."
docker-compose -f _docker-compose.yml build
break 2
;;
rb | rebuild)
ba | build-act)
cd $directory/../_docker
printDgMsg "Rebuilding ${2}..."
docker-compose -f _docker-compose.yml build --no-cache
printDgMsg "Building act testing image..."
docker buildx build . -t github-actions-test -f act.Dockerfile --platform linux/amd64
break 2
;;
bf | build-front)
printDgMsg "Building ${front_img}..."
docker-compose -f _docker-compose.yml build front
break 2
;;
rbf | rebuild-front)
rb | rebuild)
cd $directory/../_docker
printDgMsg "Rebuilding ${2}..."
docker-compose -f _docker-compose.yml build front --no-cache
break 2
;;
bb | build-back)
cd $directory/../_docker
printDgMsg "Building ${back_img}..."
docker-compose -f _docker-compose.yml build back
docker-compose -f _docker-compose.yml build --no-cache
break 2
;;
r | run)
Expand All @@ -47,33 +37,7 @@ else
docker-compose -f _docker-compose.yml up
break 2
;;
rba | run-back)
printDgMsg "Running local ${back_img}..."
docker run -p 1337:1337 -it ${back_img}
break 2
;;
rf | run-front)
printDgMsg "Running local ${front_img}..."
docker run -p 80:3000 -it ${front_img}
break 2
;;
p | push)
printDgMsg "Pushing ${front_img}..."
aws ecr get-login-password --region ${region} |
docker login --username AWS --password-stdin ${front_ecr_uri}
tag ${front_img} ${front_ecr_uri}
# archive ${front_ecr_uri}
docker push ${front_ecr_uri}:latest
# -----------------
printDgMsg "Pushing ${back_img}..."
aws ecr get-login-password --region ${region} |
docker login --username AWS --password-stdin ${back_ecr_uri}
tag ${back_img} ${back_ecr_uri}
# archive ${back_ecr_uri}
docker push ${back_ecr_uri}:latest
break 2
;;
pb | push-back)
p | push | pb | push-back)
printDgMsg "Pushing ${back_img}..."
aws ecr get-login-password --region ${region} |
docker login --username AWS --password-stdin ${back_ecr_uri}
Expand All @@ -82,20 +46,11 @@ else
docker push ${back_ecr_uri}:latest
break 2
;;
pf | push-front)
printDgMsg "Pushing ${front_img}..."
aws ecr get-login-password --region ${region} |
docker login --username AWS --password-stdin ${front_ecr_uri}
tag ${front_img} ${front_ecr_uri}
# archive ${front_ecr_uri}:latest
docker push ${front_ecr_uri}:latest
break 2
;;
*)
printDgErr "Unexpected options for docker: wrong docker args."
break 2
;;
esac
shred
done
shredBackEnv
fi
2 changes: 1 addition & 1 deletion _utils/_scripts/front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ while test "$1" != --; do
;;
esac
done
shredFrontEnv
shred
Loading

0 comments on commit 484413e

Please sign in to comment.