Skip to content

Commit 393729b

Browse files
committed
Initial AppEngine Deployment from the local machine
1 parent ace2b9d commit 393729b

19 files changed

+4590
-261
lines changed

.DS_Store

6 KB
Binary file not shown.

.dockerignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.gcloudignore
2+
.git
3+
.gitignore
4+
.eslintrc.json
5+
.markdownlint.yaml
6+
.prettierignore
7+
.prettierrc.json
8+
.reviewdog.yaml
9+
.yamllint.yaml
10+
nodemon.json
11+
README.md
12+
node_modules/
13+
.github/
14+
/coverage

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"env": {
33
"browser": true,
44
"commonjs": true,
5-
"es2021": true
5+
"es2021": true,
6+
"node": true
67
},
78
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
89
"parserOptions": {

.gcloudignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.gcloudignore
2+
.git
3+
.gitignore
4+
.eslintrc.json
5+
.markdownlint.yaml
6+
.prettierignore
7+
.prettierrc.json
8+
.reviewdog.yaml
9+
.yamllint.yaml
10+
nodemon.json
11+
README.md
12+
node_modules/
13+
.github/

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ jspm_packages/
1212
.env.test
1313
.env.production
1414
.envrc
15+
local*.yaml

.markdownlint.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
---
21
MD013:
32
line_length: 80

.reviewdog.yml .reviewdog.yaml

File renamed without changes.

.yamllint.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
---
21
extends: default
32

43
rules:
4+
document-start: false
5+
document-end: false
56
line-length:
67
max: 200
78
level: warning

Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# syntax=docker/dockerfile:1.2
2+
FROM node:16.13.1-buster-slim
3+
4+
WORKDIR /home/node
5+
COPY package.json package-lock.json ./
6+
RUN npm ci
7+
8+
COPY bin ./bin
9+
COPY src ./src
10+
11+
CMD [ "node", "bin/www" ]
12+
13+
# LABEL org.opencontainers.image.created="$BUILD_TIME"
14+
# LABEL org.opencontainers.image.title="$CI_PROJECT_NAME"
15+
# LABEL org.opencontainers.image.url="$CI_PROJECT_URL"
16+
# LABEL org.opencontainers.image.source="$CI_PROJECT_URL"
17+
# LABEL org.opencontainers.image.revision="$CI_COMMIT_SHA"

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ This repository shall serve the code for the schibbler backend API.
1010
This code is deployed to Google Cloud's App Engine from my local machine.
1111
A pipeline for testing and linting the source code is in place.
1212
A deploment pipeline might be introduced in a later stage.
13+
14+
### Steps to deploy

app.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
service: default
2+
runtime: nodejs16
3+
entrypoint: "node bin/www"
4+
instance_class: B2
5+
basic_scaling:
6+
max_instances: 2
7+
idle_timeout: 5m
8+
env_variables:
9+
APP_LOG_LEVEL: info
10+
APP_LOG_SOURCE: true

bin/www

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/usr/bin/env node
2-
2+
require("@google-cloud/trace-agent").start()
3+
require("@google-cloud/debug-agent").start({
4+
serviceContext: { enableCanary: true },
5+
})
36
const app = require("../src/app")
4-
const bunyan = require("bunyan")
57
const http = require("http")
6-
const config = require("config")
7-
88
const log = require("../src/logger")("schibbler-server")
9+
10+
const defaultPort = 8080
11+
912
const normalizePort = (portValue) => {
1013
const port = parseInt(portValue, 10)
1114

@@ -25,20 +28,7 @@ const onError = (error) => {
2528
throw error
2629
}
2730

28-
var bind = typeof port === "string" ? "Pipe " + port : "Port " + port
29-
30-
switch (error.code) {
31-
case "EACCES":
32-
console.error(bind + " requires elevated privileges")
33-
process.exit(1)
34-
break
35-
case "EADDRINUSE":
36-
console.error(bind + " is already in use")
37-
process.exit(1)
38-
break
39-
default:
40-
throw error
41-
}
31+
throw error
4232
}
4333

4434
const onListening = () => {
@@ -48,7 +38,7 @@ const onListening = () => {
4838
log.info("Server started and Listening on " + bind)
4939
}
5040

51-
const port = normalizePort(config.get("server.port"))
41+
const port = normalizePort(process.env.PORT || defaultPort)
5242
app.set("port", port)
5343

5444
const server = http.createServer(app)

config/default.yaml

-5
This file was deleted.

config/development.yaml

-4
This file was deleted.

0 commit comments

Comments
 (0)