Skip to content

Commit

Permalink
Merge pull request #225 from green-ecolution/release/v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
choffmann authored Oct 21, 2024
2 parents c0b0e1d + 30f1be6 commit cd3f4a7
Show file tree
Hide file tree
Showing 216 changed files with 13,886 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#############################################
# Builder web
#############################################
FROM openapitools/openapi-generator-cli AS openapi-builder

USER root
RUN echo "java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar \$@" > /usr/local/bin/openapi-generator-cli \
&& chmod +x /usr/local/bin/openapi-generator-cli

WORKDIR /app

COPY ./backend-client/api-docs.json ./backend-client/openapi-generator.sh ./

RUN ./openapi-generator.sh local

#############################################
# Builder web
#############################################
FROM node:20-alpine AS builder-web

ENV VITE_BACKEND_BASEURL=/api
WORKDIR /app/build
COPY ./backend-client/package.json ./backend-client/
COPY ./frontend/package.json ./frontend/
COPY ./yarn.lock ./package.json ./
RUN yarn --frozen-lockfile

COPY ./backend-client/tsconfig.json ./backend-client/
COPY --from=openapi-builder /app/src ./backend-client/src
RUN yarn build:backend-client

COPY ./frontend ./frontend
RUN yarn build:frontend:dev

#############################################
# Nginx
#############################################
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/frontend/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

46 changes: 46 additions & 0 deletions .docker/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#############################################
# Builder web
#############################################
FROM openapitools/openapi-generator-cli AS openapi-builder

USER root
RUN echo "java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar \$@" > /usr/local/bin/openapi-generator-cli \
&& chmod +x /usr/local/bin/openapi-generator-cli

WORKDIR /app

COPY ./backend-client/api-docs.json ./backend-client/openapi-generator.sh ./

RUN ./openapi-generator.sh local

#############################################
# Builder web
#############################################
FROM node:20-alpine AS builder-web

ENV VITE_BACKEND_BASEURL=/api
WORKDIR /app/build
COPY ./backend-client/package.json ./backend-client/
COPY ./frontend/package.json ./frontend/
COPY ./yarn.lock ./package.json ./
RUN yarn --frozen-lockfile

COPY ./backend-client/tsconfig.json ./backend-client/
COPY --from=openapi-builder /app/src ./backend-client/src
RUN yarn build:backend-client

COPY ./frontend ./frontend
RUN yarn build:frontend

#############################################
# Nginx
#############################################
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/frontend/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

46 changes: 46 additions & 0 deletions .docker/Dockerfile.stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#############################################
# Builder web
#############################################
FROM openapitools/openapi-generator-cli AS openapi-builder

USER root
RUN echo "java -jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar \$@" > /usr/local/bin/openapi-generator-cli \
&& chmod +x /usr/local/bin/openapi-generator-cli

WORKDIR /app

COPY ./backend-client/api-docs.json ./backend-client/openapi-generator.sh ./

RUN ./openapi-generator.sh local

#############################################
# Builder web
#############################################
FROM node:20-alpine AS builder-web

ENV VITE_BACKEND_BASEURL=/api
WORKDIR /app/build
COPY ./backend-client/package.json ./backend-client/
COPY ./frontend/package.json ./frontend/
COPY ./yarn.lock ./package.json ./
RUN yarn --frozen-lockfile

COPY ./backend-client/tsconfig.json ./backend-client/
COPY --from=openapi-builder /app/src ./backend-client/src
RUN yarn build:backend-client

COPY ./frontend ./frontend
RUN yarn build:frontend:stage

#############################################
# Nginx
#############################################
FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf
COPY .docker/nginx.conf /etc/nginx/conf.d/
COPY --from=builder-web /app/build/frontend/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

9 changes: 9 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;
listen [::]:80;

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
}
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

backend-client/**
!backend-client/openapi-generator.sh
!backend-client/api-docs.json
!backend-client/package.json
!backend-client/tsconfig.json
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{ts,tsx,json}]
indent_style = space
indent_size = 2
74 changes: 74 additions & 0 deletions .github/workflows/build-and-push-develop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and Push Docker Image Develop
"on":
push:
branches:
- develop

jobs:
build_and_deploy_dev:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true

- name: Set commit sha
run: |
echo "COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: set lower case owner name
run: |
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: "${{ github.repository }}"

- name: get build time
run: |
echo "BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>${GITHUB_ENV}
- name: Get api docs artifacts
env:
GH_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: |
gh run download -R green-ecolution/green-ecolution-backend -n api-docs.json
mv api-docs.json ./backend-client/api-docs.json
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
APP_VERSION="development"
APP_GIT_COMMIT=${{env.COMMIT_SHA}}
APP_GIT_BRANCH="develop"
APP_BUILD_TIME=${{env.BUILD_TIME}}
APP_GIT_REPOSITORY=${{github.repository}}
file: ./.docker/Dockerfile.dev
platforms: linux/amd64 #,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-dev:latest, ghcr.io/${{ env.REPO_LC }}-dev:${{ env.COMMIT_SHA }}

- name: Notify management repo to update submodules
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
repository: green-ecolution/green-ecolution-management
event-type: "update-submodules"
114 changes: 114 additions & 0 deletions .github/workflows/build-and-push-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build and Push Docker Image Production

on:
pull_request:
branches:
- main
types:
- closed

jobs:
build_and_deploy_prod:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true &&
(startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
permissions:
contents: write
packages: write
actions: write
pull-requests: write
steps:
- name: Extract version from branch name (for release branches)
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from branch name (for hotfix branches)
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Release
uses: thomaseizinger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
tag_name: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false

- name: Merge main into develop branch
uses: thomaseizinger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: main
base: develop
title: Merge main into develop branch
body: |
This PR merges the main branch back into develop.
This happens to ensure that the updates that happend on the release branch, i.e. CHANGELOG and manifest updates are also present on the develop branch.
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: set lower case owner name
run: |
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: "${{ github.repository }}"

- name: get build time
run: |
echo "BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>${GITHUB_ENV}
- name: Get api docs artifacts
env:
GH_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: |
gh run download -R green-ecolution/green-ecolution-backend -n api-docs-${{ env.RELEASE_VERSION }}.json
mv api-docs-${{ env.RELEASE_VERSION }}.json ./backend-client/api-docs.json
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
APP_VERSION=${{env.RELEASE_VERSION}}
APP_GIT_COMMIT=${{env.COMMIT_SHA}}
APP_GIT_BRANCH=main
APP_BUILD_TIME=${{env.BUILD_TIME}}
APP_GIT_REPOSITORY=${{github.repository}}
file: ./.docker/Dockerfile.prod
platforms: linux/amd64
push: true
tags: ghcr.io/${{ env.REPO_LC }}:${{ env.RELEASE_VERSION }}, ghcr.io/${{ env.REPO_LC }}:latest

- name: Notify management repo to update submodules
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
repository: green-ecolution/green-ecolution-management
event-type: "update-submodules-production"
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ env.COMMIT_SHA }}", "version": "${{ env.RELEASE_VERSION }}", "from": "frontend"}'

Loading

0 comments on commit cd3f4a7

Please sign in to comment.