From d7fe90975096dcb9e887ca1234854a85469731a3 Mon Sep 17 00:00:00 2001 From: gillettmoj Date: Thu, 28 Nov 2024 14:46:58 +0000 Subject: [PATCH] Uml 3727 build image (#2968) * Update docker file * go mod init * Add go lambda * Update Dockerfile * update build and push actions * Update build and push * Update path in build and push * Update go ver * Update ingestion lambda * Update dockerfile * Update dockerfile * Update DockerFile --- .github/workflows/_build-and-push.yml | 11 ++++++++++- lambda-functions/ingestion-lambda/Dockerfile | 4 ++-- lambda-functions/ingestion-lambda/app/main.go | 17 +++++++++++++++++ lambda-functions/ingestion-lambda/go.mod | 5 +++++ lambda-functions/ingestion-lambda/go.sum | 2 ++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 lambda-functions/ingestion-lambda/app/main.go create mode 100644 lambda-functions/ingestion-lambda/go.mod create mode 100644 lambda-functions/ingestion-lambda/go.sum diff --git a/.github/workflows/_build-and-push.yml b/.github/workflows/_build-and-push.yml index c153688919..a3dfad15e1 100644 --- a/.github/workflows/_build-and-push.yml +++ b/.github/workflows/_build-and-push.yml @@ -75,6 +75,12 @@ jobs: run_unit_tests: 'true' run_integration_tests: 'false' artifact_to_dl: '' + - svc_prefix: 'ingestion' + svc_suffix: 'lambda' + build_development_docker: 'false' + run_unit_tests: 'false' + run_integration_tests: 'false' + artifact_to_dl: '' steps: - uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb @@ -255,9 +261,12 @@ jobs: docker build --file service-${SVC_PREFIX}/docker/web/Dockerfile --tag ${SVC_PREFIX}_web:latest . - elif [[ "${SVC_SUFFIX}" = "lambda" ]]; then + elif [[ "${SVC_PREFIX}" = "stats_upload" ]]; then docker build --no-cache --file lambda-functions/upload-statistics/Dockerfile --tag stats_upload_lambda:latest lambda-functions/upload-statistics + elif [[ "${SVC_PREFIX}" = "ingestion" ]]; then + docker build --file lambda-functions/ingestion-lambda/Dockerfile --tag ingestion_lambda:latest lambda-functions/ingestion-lambda + fi if: (inputs.specific_path == 'all' || inputs.specific_path == matrix.svc_prefix) diff --git a/lambda-functions/ingestion-lambda/Dockerfile b/lambda-functions/ingestion-lambda/Dockerfile index 2d5928bb2d..e065e01c3b 100644 --- a/lambda-functions/ingestion-lambda/Dockerfile +++ b/lambda-functions/ingestion-lambda/Dockerfile @@ -6,9 +6,9 @@ COPY go.mod go.sum ./ RUN go mod download -COPY cmd/ingestion ./cmd/ingestion +COPY app/ ./ -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /go/bin/ingestion ./cmd/ingestion +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /go/bin/ingestion ./ FROM scratch AS production diff --git a/lambda-functions/ingestion-lambda/app/main.go b/lambda-functions/ingestion-lambda/app/main.go new file mode 100644 index 0000000000..7a74dacd67 --- /dev/null +++ b/lambda-functions/ingestion-lambda/app/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "context" + "fmt" + + "github.com/aws/aws-lambda-go/lambda" +) + +func Handler(ctx context.Context) (string, error) { + fmt.Println("Hello World") + return "Hello World!", nil +} + +func main() { + lambda.Start(Handler) +} diff --git a/lambda-functions/ingestion-lambda/go.mod b/lambda-functions/ingestion-lambda/go.mod new file mode 100644 index 0000000000..f44c3becbb --- /dev/null +++ b/lambda-functions/ingestion-lambda/go.mod @@ -0,0 +1,5 @@ +module github.com/ministryofjustice/opg-use-an-lpa + +go 1.23.1 + +require github.com/aws/aws-lambda-go v1.47.0 // indirect diff --git a/lambda-functions/ingestion-lambda/go.sum b/lambda-functions/ingestion-lambda/go.sum new file mode 100644 index 0000000000..23a2b4057f --- /dev/null +++ b/lambda-functions/ingestion-lambda/go.sum @@ -0,0 +1,2 @@ +github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= +github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=