Skip to content

Commit

Permalink
initial heroku adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasfroeller committed Apr 29, 2024
1 parent 142c6e2 commit 818af88
Show file tree
Hide file tree
Showing 17 changed files with 1,193 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEV_MODE="true"
HEROKU_API_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
DEV_ACCESS_PASSPHRASE="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
53 changes: 53 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Continuous Deployment - Development Backend Service
on: ["push", "pull_request"]
#workflow_run:
# workflows: ["Continuous Integration - Development Backend Service"]
# types:
# - completed
permissions: write-all

jobs:
cd:
runs-on: ubuntu-latest

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: Login to Leo Cloud Container Registry
uses: docker/login-action@v3
with:
registry: registry.cloud.htl-leonding.ac.at
username: ${{ secrets.LEOCLOUD_EMAIL }}
password: ${{ secrets.LEOCLOUD_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: |
propromo/rest-microservice:latest
ghcr.io/${{ github.repository_owner }}/propromo-rest-microservice:latest
registry.cloud.htl-leonding.ac.at/j.froeller/rest-microservice:latest
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release - Development Backend Service
on:
workflow_run:
workflows: ["Continuous Deployment - Development Backend Service"]
types:
- completed
permissions: write-all

jobs:
release:
runs-on: ubuntu-latest

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

- name: Get latest release tag
id: get_latest_tag
run: |
# LATEST_TAG=$(git ls-remote --tags origin | grep -v '^{}' | grep -v '^{} ' | awk '{print $2}' | sed 's/refs\/tags\///' | sort -V | tail -n 1)
git pull --tags
LATEST_TAG=$(git tag --sort=-version:refname | head -n 1)
echo "latest_remote_tag=${LATEST_TAG}"
if [[ -z "${LATEST_TAG}" || ! "${LATEST_TAG}" =~ $(date +"%Y.%m.%d") ]]; then
TAG=$(date +"%Y.%m.%d.1")
echo "creating new tag: latest_tag=${TAG}" >> $GITHUB_ENV
else
echo "using remote tag: latest_tag=${LATEST_TAG}" >> $GITHUB_ENV
fi
- name: Generate release tag
id: generate_release_tag
run: |
if [[ -z "${latest_tag}" ]]; then
TAG=$(date +"%Y.%m.%d.1")
else
IFS='.' read -r YYYY MM DD I <<< "${latest_tag}"
echo "latest_tag=$latest_tag"
echo "YYYY=$YYYY"
echo "MM=$MM"
echo "DD=$DD"
echo "I=$I"
TAG="${YYYY}.${MM}.${DD}.$((I+1))"
echo "TAG=$TAG"
fi
echo "next_release_tag=${TAG}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ steps.generate_release_tag.outputs.next_release_tag }}
name: Release ${{ steps.generate_release_tag.outputs.next_release_tag }}
generateReleaseNotes: true
draft: false
prerelease: true
makeLatest: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
node_modules
.env
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:20.12-bookworm-slim AS development

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build


FROM node:20.12-bullseye AS production

WORKDIR /usr/src/app

RUN curl https://cli-assets.heroku.com/install.sh | sh
ENV PATH="${PATH}:/usr/local/bin/heroku"
RUN echo 'export PATH="/usr/local/bin/heroku:$PATH"' >> ~/.bashrc
RUN . ~/.bashrc
RUN heroku --version

COPY package*.json ./

RUN npm install --only=production

COPY --from=development /usr/src/app/build ./build

EXPOSE 80

CMD ["node", "build/index.js"]
22 changes: 18 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ var tsc = require('gulp-tsc');
var shell = require('gulp-shell');
var runseq = require('run-sequence');
var tslint = require('gulp-tslint');
var babel = require('gulp-babel');

var paths = {
tscripts : { src : ['src/**/*.ts'],
dest : 'build' }
dest: 'build'
},
jsscripts: {
src: ['src/**/*.js'],
dest: 'build'
}
};

gulp.task('default', ['lint', 'buildrun']);
Expand All @@ -24,16 +30,17 @@ gulp.task('buildrun', function (cb) {
// ** Watching ** //

gulp.task('watch', function () {
gulp.watch(paths.tscripts.src, ['compile:typescript']);
gulp.watch(paths.tscripts.src, ['compile']);
});

gulp.task('watchrun', function () {
gulp.watch(paths.tscripts.src, runseq('compile:typescript', 'run'));
gulp.watch(paths.tscripts.src, runseq('compile', 'run'));
});

// ** Compilation ** //

gulp.task('build', ['compile:typescript']);
gulp.task('build', ['compile']);
gulp.task('compile', ['compile:typescript', 'compile:javascript']);
gulp.task('compile:typescript', function () {
return gulp
.src(paths.tscripts.src)
Expand All @@ -44,6 +51,13 @@ gulp.task('compile:typescript', function () {
.pipe(gulp.dest(paths.tscripts.dest));
});

gulp.task('compile:javascript', function () {
return gulp
.src(paths.jsscripts.src)
.pipe(babel())
.pipe(gulp.dest(paths.jsscripts.dest));
});

// ** Linting ** //

gulp.task('lint', ['lint:default']);
Expand Down
13 changes: 0 additions & 13 deletions index.mjs

This file was deleted.

Loading

0 comments on commit 818af88

Please sign in to comment.