Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
feat: add proxy app for RKN
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Apr 8, 2019
1 parent 13cdc25 commit 5683b2c
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.secure
node_modules
1 change: 0 additions & 1 deletion .dockerognore

This file was deleted.

12 changes: 12 additions & 0 deletions .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ action "Build front image" {
needs = ["Login to Docker"]
}

action "Build proxy image" {
uses = "actions/docker/cli@8cdf801b322af5f369e00d85e9cf3a7122f49108"
args = "build -t igorkamyshev/checkmoney-proxy -f Dockerfile-proxy ."
needs = ["Login to Docker"]
}

action "Push back image" {
uses = "actions/docker/cli@8cdf801b322af5f369e00d85e9cf3a7122f49108"
args = "push igorkamyshev/checkmoney-back"
Expand All @@ -75,6 +81,12 @@ action "Push front image" {
needs = ["Build front image"]
}

action "Push proxy image" {
uses = "actions/docker/cli@8cdf801b322af5f369e00d85e9cf3a7122f49108"
args = "push igorkamyshev/checkmoney-proxy"
needs = ["Build proxy image"]
}

action "Deploy on server" {
uses = "maddox/actions/ssh@master"
needs = ["Push front image", "Push back image"]
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile-proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM keymetrics/pm2:10-alpine

RUN echo -e 'http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community\nhttp://dl-cdn.alpinelinux.org/alpine/edge/testing' > /etc/apk/repositories
RUN apk add --no-cache yarn git

WORKDIR /app

COPY . .

RUN yarn

WORKDIR /app/proxy

EXPOSE 3000

ENV NODE_ENV="production"

CMD [ "pm2-docker", "start", "pm2.config.js" ]
8 changes: 8 additions & 0 deletions proxy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Fastify = require('fastify')
const server = Fastify()

server.register(require('fastify-http-proxy'), {
upstream: process.env.BACK_URL || 'https://api.checkmoney.space',
})

server.listen(3000)
13 changes: 13 additions & 0 deletions proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "checkmoney-proxy",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start:proxy:prod": "pm2 start ./pm2.config.js"
},
"dependencies": {
"fastify": "^2.2.0",
"fastify-http-proxy": "^2.1.0"
}
}
13 changes: 13 additions & 0 deletions proxy/pm2.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
apps: [
{
name: 'checkmoney-proxy',
script: 'index.js',
watch: false,
instances: 'max',
exec_mode: 'cluster',
merge_logs: true,
env_production: { NODE_ENV: 'production' },
},
],
}
Loading

0 comments on commit 5683b2c

Please sign in to comment.