mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
shortner > shortener
This commit is contained in:
parent
9b797b5eed
commit
3520e834eb
4
.github/workflows/compile.yml
vendored
4
.github/workflows/compile.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
|||||||
- run: cd CommonServer && npm install
|
- run: cd CommonServer && npm install
|
||||||
- run: cd ApiReference && npm install && npm run compile
|
- run: cd ApiReference && npm install && npm run compile
|
||||||
|
|
||||||
compile-link-shortner:
|
compile-link-shortener:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
CI_PIPELINE_ID: ${{github.run_number}}
|
CI_PIPELINE_ID: ${{github.run_number}}
|
||||||
@ -51,7 +51,7 @@ jobs:
|
|||||||
- run: cd Common && npm install
|
- run: cd Common && npm install
|
||||||
- run: cd Model && npm install
|
- run: cd Model && npm install
|
||||||
- run: cd CommonServer && npm install
|
- run: cd CommonServer && npm install
|
||||||
- run: cd LinkShortner && npm install && npm run compile
|
- run: cd LinkShortener && npm install && npm run compile
|
||||||
|
|
||||||
compile-common-server:
|
compile-common-server:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
4
.github/workflows/docker-build.yml
vendored
4
.github/workflows/docker-build.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: build docker image
|
- name: build docker image
|
||||||
run: sudo docker build -f ./Accounts/Dockerfile .
|
run: sudo docker build -f ./Accounts/Dockerfile .
|
||||||
|
|
||||||
docker-build-link-shortner:
|
docker-build-link-shortener:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
CI_PIPELINE_ID: ${{github.run_number}}
|
CI_PIPELINE_ID: ${{github.run_number}}
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
|
|
||||||
# build image for accounts service
|
# build image for accounts service
|
||||||
- name: build docker image
|
- name: build docker image
|
||||||
run: sudo docker build -f ./LinkShortner/Dockerfile .
|
run: sudo docker build -f ./LinkShortener/Dockerfile .
|
||||||
|
|
||||||
docker-build-api-reference:
|
docker-build-api-reference:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -216,7 +216,7 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
link-shortner-docker-image-deploy:
|
link-shortener-docker-image-deploy:
|
||||||
needs: generate-build-number
|
needs: generate-build-number
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@ -225,8 +225,8 @@ jobs:
|
|||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
oneuptime/link-shortner
|
oneuptime/link-shortener
|
||||||
ghcr.io/oneuptime/link-shortner
|
ghcr.io/oneuptime/link-shortener
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=test,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=test,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
type=semver,value=7.0.${{needs.generate-build-number.outputs.build_number}}-test,pattern={{version}},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=semver,value=7.0.${{needs.generate-build-number.outputs.build_number}}-test,pattern={{version}},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
@ -250,7 +250,7 @@ jobs:
|
|||||||
- name: Generate Dockerfile from Dockerfile.tpl
|
- name: Generate Dockerfile from Dockerfile.tpl
|
||||||
run: npm run prerun
|
run: npm run prerun
|
||||||
|
|
||||||
# Build and deploy link-shortner.
|
# Build and deploy link-shortener.
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2.2.0
|
uses: docker/login-action@v2.2.0
|
||||||
@ -268,7 +268,7 @@ jobs:
|
|||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
file: ./LinkShortner/Dockerfile
|
file: ./LinkShortener/Dockerfile
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
|
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -57,8 +57,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "127.0.0.1",
|
"address": "127.0.0.1",
|
||||||
"localRoot": "${workspaceFolder}/LinkShortner",
|
"localRoot": "${workspaceFolder}/LinkShortener",
|
||||||
"name": "Link Shortner: Debug with Docker",
|
"name": "Link Shortener: Debug with Docker",
|
||||||
"port": 9826,
|
"port": 9826,
|
||||||
"remoteRoot": "/usr/src/app",
|
"remoteRoot": "/usr/src/app",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
|
@ -66,8 +66,8 @@ export const WorkerHostname: Hostname = Hostname.fromString(
|
|||||||
process.env['WORKER_HOSTNAME'] || 'worker'
|
process.env['WORKER_HOSTNAME'] || 'worker'
|
||||||
);
|
);
|
||||||
|
|
||||||
export const LinkShortnerHostname: Route = new Route(
|
export const LinkShortenerHostname: Route = new Route(
|
||||||
process.env['LINK_SHORTNER_HOSTNAME'] || 'link-shortner'
|
process.env['LINK_SHORTENER_HOSTNAME'] || 'link-shortener'
|
||||||
);
|
);
|
||||||
|
|
||||||
export const WorkflowHostname: Hostname = Hostname.fromString(
|
export const WorkflowHostname: Hostname = Hostname.fromString(
|
||||||
@ -128,8 +128,8 @@ export const StatusPageRoute: Route = new Route(
|
|||||||
process.env['STATUS_PAGE_ROUTE'] || '/status-page'
|
process.env['STATUS_PAGE_ROUTE'] || '/status-page'
|
||||||
);
|
);
|
||||||
|
|
||||||
export const LinkShortnerRoute: Route = new Route(
|
export const LinkShortenerRoute: Route = new Route(
|
||||||
process.env['LINK_SHORTNER_ROUTE'] || '/l'
|
process.env['LINK_SHORTENER_ROUTE'] || '/l'
|
||||||
);
|
);
|
||||||
|
|
||||||
export const DashboardRoute: Route = new Route(
|
export const DashboardRoute: Route = new Route(
|
||||||
|
@ -4,7 +4,7 @@ import DatabaseService, { OnCreate } from './DatabaseService';
|
|||||||
import CreateBy from '../Types/Database/CreateBy';
|
import CreateBy from '../Types/Database/CreateBy';
|
||||||
import Text from 'Common/Types/Text';
|
import Text from 'Common/Types/Text';
|
||||||
import URL from 'Common/Types/API/URL';
|
import URL from 'Common/Types/API/URL';
|
||||||
import { Domain, HttpProtocol, LinkShortnerRoute } from '../Config';
|
import { Domain, HttpProtocol, LinkShortenerRoute } from '../Config';
|
||||||
import Route from 'Common/Types/API/Route';
|
import Route from 'Common/Types/API/Route';
|
||||||
|
|
||||||
export class Service extends DatabaseService<Model> {
|
export class Service extends DatabaseService<Model> {
|
||||||
@ -31,7 +31,7 @@ export class Service extends DatabaseService<Model> {
|
|||||||
return new URL(
|
return new URL(
|
||||||
HttpProtocol,
|
HttpProtocol,
|
||||||
Domain,
|
Domain,
|
||||||
new Route(LinkShortnerRoute.toString()).addRoute(
|
new Route(LinkShortenerRoute.toString()).addRoute(
|
||||||
'/' + model.shortId?.toString()
|
'/' + model.shortId?.toString()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# OneUptime-LinkShortner Dockerfile
|
# OneUptime-LinkShortener Dockerfile
|
||||||
#
|
#
|
||||||
|
|
||||||
# Pull base image nodejs image.
|
# Pull base image nodejs image.
|
||||||
@ -54,12 +54,12 @@ RUN mkdir /usr/src/app
|
|||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
COPY ./LinkShortner/package*.json /usr/src/app/
|
COPY ./LinkShortener/package*.json /usr/src/app/
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
|
|
||||||
# Expose ports.
|
# Expose ports.
|
||||||
# - 3088: OneUptime-LinkShortner
|
# - 3088: OneUptime-LinkShortener
|
||||||
EXPOSE 3521
|
EXPOSE 3521
|
||||||
|
|
||||||
{{ if eq .Env.ENVIRONMENT "development" }}
|
{{ if eq .Env.ENVIRONMENT "development" }}
|
||||||
@ -67,7 +67,7 @@ EXPOSE 3521
|
|||||||
CMD [ "npm", "run", "dev" ]
|
CMD [ "npm", "run", "dev" ]
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# Copy app source
|
# Copy app source
|
||||||
COPY ./LinkShortner /usr/src/app
|
COPY ./LinkShortener /usr/src/app
|
||||||
# Bundle app source
|
# Bundle app source
|
||||||
RUN npm run compile
|
RUN npm run compile
|
||||||
#Run the app
|
#Run the app
|
||||||
|
@ -2,13 +2,13 @@ import Express, { ExpressApplication } from 'CommonServer/Utils/Express';
|
|||||||
import App from 'CommonServer/Utils/StartServer';
|
import App from 'CommonServer/Utils/StartServer';
|
||||||
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
|
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
|
||||||
import logger from 'CommonServer/Utils/Logger';
|
import logger from 'CommonServer/Utils/Logger';
|
||||||
import LinkShortnerAPI from './API/LinkShortner';
|
import LinkShortenerAPI from './API/LinkShortener';
|
||||||
|
|
||||||
const APP_NAME: string = 'l';
|
const APP_NAME: string = 'l';
|
||||||
|
|
||||||
const app: ExpressApplication = Express.getExpressApp();
|
const app: ExpressApplication = Express.getExpressApp();
|
||||||
|
|
||||||
app.use([`/${APP_NAME}/`, '/'], LinkShortnerAPI);
|
app.use([`/${APP_NAME}/`, '/'], LinkShortenerAPI);
|
||||||
|
|
||||||
const init: Function = async (): Promise<void> => {
|
const init: Function = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "linkshortner",
|
"name": "linkshortener",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@ -19,8 +19,8 @@ upstream workflow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
upstream link-shortner {
|
upstream link-shortener {
|
||||||
server link-shortner:3521 weight=10 max_fails=3 fail_timeout=30s;
|
server link-shortener:3521 weight=10 max_fails=3 fail_timeout=30s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ server {
|
|||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /l { # Short URL for Link Shortner
|
location /l { # Short URL for Link Shortener
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@ -329,7 +329,7 @@ server {
|
|||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_pass http://link-shortner;
|
proxy_pass http://link-shortener;
|
||||||
|
|
||||||
client_max_body_size 50M;
|
client_max_body_size 50M;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ NOTIFICATION_HOSTNAME=notification:3191
|
|||||||
DASHBOARD_HOSTNAME=dashboard:3000
|
DASHBOARD_HOSTNAME=dashboard:3000
|
||||||
DASHBOARD_API_HOSTNAME=dashboard-api:3002
|
DASHBOARD_API_HOSTNAME=dashboard-api:3002
|
||||||
WORKFLOW_HOSTNAME=workflow:3099
|
WORKFLOW_HOSTNAME=workflow:3099
|
||||||
LINK_SHORTNER_HOSTNAME=link-shortner:3521
|
LINK_SHORTENER_HOSTNAME=link-shortener:3521
|
||||||
ALERT_HOSTNAME=alert:3088
|
ALERT_HOSTNAME=alert:3088
|
||||||
PROBE_API_HOSTNAME=probe-api:3400
|
PROBE_API_HOSTNAME=probe-api:3400
|
||||||
TEST_SERVER_HOSTNAME=test-server:3800
|
TEST_SERVER_HOSTNAME=test-server:3800
|
||||||
@ -90,7 +90,7 @@ NOTIFICATION_ROUTE=/notification
|
|||||||
DASHBOARD_ROUTE=/dashboard
|
DASHBOARD_ROUTE=/dashboard
|
||||||
DASHBOARD_API_ROUTE=/api
|
DASHBOARD_API_ROUTE=/api
|
||||||
WORKFLOW_ROUTE=/workflow
|
WORKFLOW_ROUTE=/workflow
|
||||||
LINK_SHORTNER_ROUTE=/l
|
LINK_SHORTENER_ROUTE=/l
|
||||||
ALERT_ROUTE=/alert
|
ALERT_ROUTE=/alert
|
||||||
TEST_SERVER_API_ROUTE=/test-server
|
TEST_SERVER_API_ROUTE=/test-server
|
||||||
PROBE_API_ROUTE=/probe-api
|
PROBE_API_ROUTE=/probe-api
|
||||||
@ -107,7 +107,7 @@ STATUS_PAGE_ROUTE=/status-page
|
|||||||
DASHBOARD_API_PORT=3002
|
DASHBOARD_API_PORT=3002
|
||||||
API_DOCS_PORT=1445
|
API_DOCS_PORT=1445
|
||||||
WORKFLOW_PORT=3099
|
WORKFLOW_PORT=3099
|
||||||
LINK_SHORTNER_PORT=3521
|
LINK_SHORTENER_PORT=3521
|
||||||
ALERT_PORT=3088
|
ALERT_PORT=3088
|
||||||
PROBE_API_PORT=3400
|
PROBE_API_PORT=3400
|
||||||
PROBE_PORT=3500
|
PROBE_PORT=3500
|
||||||
|
@ -206,13 +206,13 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
link-shortner:
|
link-shortener:
|
||||||
networks:
|
networks:
|
||||||
- oneuptime
|
- oneuptime
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
<<: *common-server-variables
|
<<: *common-server-variables
|
||||||
PORT: ${LINK_SHORTNER_PORT}
|
PORT: ${LINK_SHORTENER_PORT}
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- postgres
|
- postgres
|
||||||
|
@ -159,9 +159,9 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
link-shortner:
|
link-shortener:
|
||||||
volumes:
|
volumes:
|
||||||
- ./LinkShortner:/usr/src/app
|
- ./LinkShortener:/usr/src/app
|
||||||
# Use node modules of the container and not host system.
|
# Use node modules of the container and not host system.
|
||||||
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
|
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
|
||||||
- /usr/src/app/node_modules/
|
- /usr/src/app/node_modules/
|
||||||
@ -175,13 +175,13 @@ services:
|
|||||||
- /usr/src/Model/node_modules/
|
- /usr/src/Model/node_modules/
|
||||||
extends:
|
extends:
|
||||||
file: ./docker-compose.base.yml
|
file: ./docker-compose.base.yml
|
||||||
service: link-shortner
|
service: link-shortener
|
||||||
ports:
|
ports:
|
||||||
- '9826:9229' # Debugging port.
|
- '9826:9229' # Debugging port.
|
||||||
build:
|
build:
|
||||||
network: host
|
network: host
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./LinkShortner/Dockerfile
|
dockerfile: ./LinkShortener/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
workflow:
|
workflow:
|
||||||
|
@ -64,11 +64,11 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
link-shortner:
|
link-shortener:
|
||||||
image: oneuptime/link-shortner:${APP_TAG}
|
image: oneuptime/link-shortener:${APP_TAG}
|
||||||
extends:
|
extends:
|
||||||
file: ./docker-compose.base.yml
|
file: ./docker-compose.base.yml
|
||||||
service: link-shortner
|
service: link-shortener
|
||||||
|
|
||||||
|
|
||||||
workflow:
|
workflow:
|
||||||
|
@ -46,9 +46,9 @@ echo "Checking API Docs Server Status..."
|
|||||||
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/reference/status)" != "200" ]]; do sleep 5; done'
|
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/reference/status)" != "200" ]]; do sleep 5; done'
|
||||||
echo "API Docs Server is up ✔️"
|
echo "API Docs Server is up ✔️"
|
||||||
|
|
||||||
echo "Checking Link Shortner Status..."
|
echo "Checking Link Shortener Status..."
|
||||||
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/l/status)" != "200" ]]; do sleep 5; done'
|
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/l/status)" != "200" ]]; do sleep 5; done'
|
||||||
echo "Link Shortner Server is up ✔️"
|
echo "Link Shortener Server is up ✔️"
|
||||||
|
|
||||||
echo "⌛️ OneUptime is up!"
|
echo "⌛️ OneUptime is up!"
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user