Skip to content

Instantly share code, notes, and snippets.

View MwinyiMoha's full-sized avatar

Mohammed Mwijaa MwinyiMoha

View GitHub Profile
@MwinyiMoha
MwinyiMoha / gist:40f4620a939283fdda9bc49e65759b04
Created May 17, 2017 16:56 — forked from yograterol/gist:99c8e123afecc828cb8c
"gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory" workaround
"gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory" CentOS's and Fedora +22 workaround
Install `redhat-rpm-config`
$ sudo dnf install redhat-rpm-config
const express = require( "express" );
const port = process.env.PORT || 3000;
const logRequest = (req, res, next) => {
console.log(req);
next();
}
const app = express();
{
"name": "express_api",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "node .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
{
"name": "express_api",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"prestart": "tsc -p .",
"start": "node dist/index.js",
"dev": "ts-node-dev src/index.ts",
"build": "tsc -p .",
@MwinyiMoha
MwinyiMoha / index.ts
Last active September 28, 2020 05:47
import express, {Application, Request, Response, NextFunction} from 'express';
const port = Number(process.env.PORT || 3000);
const logRequest = (req: Request, res: Response, next: NextFunction) => {
console.log(req);
next();
}
const app: Application = express();
FROM node
WORKDIR /app
COPY . .
RUN npm i
EXPOSE 3000
FROM node:14-alpine AS node
# Builder stage
FROM node AS builder
# Use /app as the CWD
WORKDIR /app
# Final stage
FROM node AS final
# Prepare destination directory and ensure user node owns it
RUN mkdir -p /home/node/app/dist && chown -R node:node /home/node/app
# Set CWD
WORKDIR /home/node/app
apps:
- name: express-typescript-api
script: ./dist/index.js
exec_mode: cluster
instances: max
# Final stage
FROM node AS final
# Set node environment to production
ENV NODE_ENV production
# Prepare destination directory and ensure user node owns it
RUN mkdir -p /home/node/app/dist && chown -R node:node /home/node/app