Skip to content

Commit 3167270

Browse files
committed
no prod port
1 parent 6508edd commit 3167270

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ app.use((err, req, res, next) => {
6767
}));
6868
});
6969

70-
// Start server
71-
const port = process.env.PORT || 8080;
72-
app.listen(port, () => {
73-
console.log(`Server listening on port ${port}`);
74-
});
70+
// For local development
71+
if (process.env.ENVIRONMENT === 'dev') {
72+
// Start server locally
73+
const port = process.env.PORT || 8080;
74+
app.listen(port, () => {
75+
console.log(`Server listening on port ${port}`);
76+
});
77+
}
7578

7679
// Export for Cloud Run
7780
exports.app = app;

terraform/dev/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ module "endpoints" {
154154
source = "./../modules/run-service"
155155
entry_point = "app"
156156
project = "httparchive"
157-
environment = "dev"
157+
environment = var.environment
158158
source_directory = "../../src"
159159
function_name = "tech-report-api"
160160
region = var.region
@@ -163,7 +163,8 @@ module "endpoints" {
163163
max_instance_request_concurrency = var.max_instance_request_concurrency
164164
min_instances = var.min_instances
165165
environment_variables = {
166-
"PROJECT" = "httparchive",
166+
"PROJECT" = var.project
167167
"DATABASE" = var.project_database
168+
"ENVIRONMENT" = var.environment
168169
}
169170
}

terraform/dev/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ variable "region" {
3030
default = "us-central1"
3131
type = string
3232
}
33+
34+
variable "environment" {
35+
description = "The environment name"
36+
type = string
37+
default = "dev"
38+
}
39+
40+
variable "project" {
41+
description = "The project name"
42+
type = string
43+
default = "httparchive"
44+
}

0 commit comments

Comments
 (0)