-
Notifications
You must be signed in to change notification settings - Fork 0
Add Java run Dockerfile #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| steps: | ||
| - name: gcr.io/cloud-builders/docker | ||
| args: | ||
| - build | ||
| - -f | ||
| - src/java/run.Dockerfile | ||
| - -t | ||
| - $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/java-run:latest | ||
| - src/java | ||
| id: BuildRunImage | ||
| - name: gcr.io/cloud-builders/docker | ||
| args: | ||
| - push | ||
| - $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/java-run:latest | ||
| id: PushRunImage | ||
| - name: gcr.io/k8s-skaffold/pack | ||
| args: | ||
| - build | ||
| - >- | ||
| $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA | ||
| - '--builder=gcr.io/buildpacks/builder:latest' | ||
| - '--run-image=$_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/java-run:latest' | ||
| - '--network=cloudbuild' | ||
| - '--path=src/java' | ||
| id: Buildpack | ||
| entrypoint: pack | ||
| - name: gcr.io/cloud-builders/docker | ||
| args: | ||
| - push | ||
| - '--all-tags' | ||
| - $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME | ||
| id: Push | ||
| - name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim | ||
| args: | ||
| - run | ||
| - services | ||
| - update | ||
| - $_SERVICE_NAME | ||
| - >- | ||
| --image=$_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA | ||
| - >- | ||
| --update-labels=managed-by=gcp-cloud-build-deploy-cloud-run,gcb-trigger-id=$_TRIGGER_ID,gcb-trigger-region=$LOCATION,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID | ||
| - '--region=$_DEPLOY_REGION' | ||
| - '--quiet' | ||
| id: Deploy | ||
| entrypoint: gcloud | ||
| images: | ||
| - >- | ||
| $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA | ||
| options: | ||
| requestedVerifyOption: VERIFIED | ||
| substitutionOption: ALLOW_LOOSE | ||
| logging: CLOUD_LOGGING_ONLY | ||
| substitutions: | ||
| _AR_REPOSITORY: cloud-run-source-deploy | ||
| _AR_PROJECT_ID: lamp-control-469416 | ||
| _SERVICE_NAME: java-lamp-control-api | ||
| _DEPLOY_REGION: europe-west1 | ||
| _TRIGGER_ID: 8f4a8369-1721-4aab-8be3-0312e689519e | ||
| _AR_HOSTNAME: europe-west1-docker.pkg.dev | ||
| tags: | ||
| - gcp-cloud-build-deploy-cloud-run | ||
| - java-lamp-control-api |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,2 @@ | ||||||||||||||||
| FROM gcr.io/buildpacks/gcp/run | ||||||||||||||||
| USER root | ||||||||||||||||
|
||||||||||||||||
| USER root | |
| # Create a non-root user with a fixed UID/GID for running the application | |
| RUN addgroup --system appgroup && adduser --system --ingroup appgroup --uid 10001 appuser | |
| # Run the application as the non-root user | |
| USER 10001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base image
gcr.io/buildpacks/gcp/runis referenced without a tag or digest, so it will pull a mutablelatestimage whose contents can change over time, which is a supply-chain risk if that upstream image is ever compromised or replaced. Because this image is used at runtime, a malicious update to the remote image would immediately affect new deployments and could run arbitrary code with access to your app’s data and secrets. Pin this base image to a specific immutable version or digest and update it intentionally as part of your release process.