Skip to content

Commit 83aaa64

Browse files
authored
Use a minimal golang http server for the GAE default service image (#49)
1 parent cee0c3a commit 83aaa64

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

gae-service-container/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# This Dockerfile is used to generate a docker image that runs an Apache Server.
16-
# The Apache server is used to run a dummy default service for the Google App Engine for opentelemetry-ops-e2e project.
17-
# The server listens at port 8080 (since this is the port which GAE listens to).
15+
# This docker image should currently be built manually and pushed to a proper location in the
16+
# artifact repository Docker image name -
17+
# us-central1-docker.pkg.dev/${PROJECT_ID}/gae-service-containers/default-service:latest
1818

19-
# This docker image should currently be built manually and pushed to a proper location in the artifact repository
20-
# Docker image name - us-central1-docker.pkg.dev/opentelemetry-ops-e2e/gae-service-containers/default-service:latest
21-
# TODO: Automate this process
22-
23-
FROM python:3-alpine
19+
FROM golang:1.22 as build
2420
EXPOSE 8080
25-
ENTRYPOINT ["python", "-m", "http.server", "8080"]
21+
COPY main.go .
22+
RUN CGO_ENABLED=0 go build -o /main main.go
23+
24+
FROM scratch
25+
COPY --from=build /main /main
26+
ENTRYPOINT ["/main"]

gae-service-container/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
)
8+
9+
func main() {
10+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
11+
fmt.Fprint(w, "Hello world")
12+
})
13+
14+
log.Fatal(http.ListenAndServe(":8080", nil))
15+
}

tf/gae-standard/gae-standard.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ variable "runtime" {
8585
}
8686

8787
variable "entrypoint" {
88-
type = string
88+
type = string
8989
default = ""
9090
}
9191

tf/persistent/gae-default-service.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
# Create the deployment for the default service in Google App Engine
1616
resource "google_app_engine_flexible_app_version" "default" {
17-
version_id = "v1"
18-
project = var.project_id
19-
service = "default"
20-
runtime = "custom"
17+
version_id = "v1"
18+
project = var.project_id
19+
service = "default"
20+
runtime = "custom"
21+
service_account = "${var.project_id}@appspot.gserviceaccount.com"
2122

2223
deployment {
2324
container {
24-
image = "us-central1-docker.pkg.dev/${var.project_id}/gae-service-containers/default-service:latest"
25+
image = "us-central1-docker.pkg.dev/${var.project_id}/gae-service-containers/default-service@sha256:70dccd7bdd8e0671fa40283be19fb5a4e4134d0cbaf1cb0d295081c05bdad34b"
2526
}
2627
}
2728

0 commit comments

Comments
 (0)