Skip to content

Commit

Permalink
Adjusted satelitte connector sample
Browse files Browse the repository at this point in the history
  • Loading branch information
reggeenr committed Oct 31, 2024
1 parent 912b98c commit 3d070ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
19 changes: 7 additions & 12 deletions satellite-connector-to-vpc-vsi/ce-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
FROM icr.io/codeengine/golang:latest AS stage

WORKDIR /app/src

FROM quay.io/projectquay/golang:1.22 AS build-env
WORKDIR /go/src/app
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o app .

FROM icr.io/codeengine/alpine

WORKDIR /app/src

COPY --from=stage /app/src/app .
RUN CGO_ENABLED=0 go build -o /go/bin/app .

CMD [ "./app" ]
# Copy the exe into a smaller base image
FROM gcr.io/distroless/static-debian12
COPY --from=build-env /go/bin/app /
CMD ["/app"]
13 changes: 9 additions & 4 deletions satellite-connector-to-vpc-vsi/ce-job/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM icr.io/codeengine/node:18-alpine

FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS build-env
WORKDIR /job

COPY *.mjs *.json /job
# Define which files should be copied into the container image
COPY --chown=default:root *.mjs *.json .

# Load all dependencies
RUN npm install

ENTRYPOINT [ "node", "job.mjs" ]
# Use a small distroless image for as runtime image
FROM gcr.io/distroless/nodejs20-debian12
COPY --from=build-env /job /job
WORKDIR /job
CMD ["job.mjs"]
18 changes: 9 additions & 9 deletions satellite-connector-to-vpc-vsi/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Env vars
CLEANUP_ON_ERROR=${CLEANUP_ON_ERROR:=true}
CLEANUP_ON_SUCCESS=${CLEANUP_ON_SUCCESS:=true}
REGION="${REGION:=us-east}"
REGION="${REGION:=eu-de}"
NAME_PREFIX="${NAME_PREFIX:=ce-to-private-vsi}"
VPC_SSH_KEY="${VPC_SSH_KEY:=}"
DEBUG_MODE="${DEBUG_MODE:=false}"
Expand Down Expand Up @@ -43,9 +43,9 @@ function print_success {
echo -e "${GREEN}$1${ENDCOLOR}"
}

# Helper function to work around the fact that the sat experimental CLI is quite limited in its current version
# Helper function to work around the fact that the sat CLI is quite limited in its current version
function getSatConnectorId() {
connector_details=$(ibmcloud sat experimental connector ls | grep -m 1 $1)
connector_details=$(ibmcloud sat connector ls | grep -m 1 $1)
if [ -z "$connector_details" ]; then
echo "not_found"
return 1
Expand Down Expand Up @@ -80,7 +80,7 @@ function clean() {

connector_id=$(getSatConnectorId $sat_connector_name)
if [[ $connector_id != 'not_found' ]]; then
ibmcloud sat experimental connector rm --connector-id $connector_id -f -q
ibmcloud sat connector rm --connector-id $connector_id -f -q
fi

ibmcloud is instance-delete $vsi_agent_name --force 2>/dev/null
Expand Down Expand Up @@ -115,7 +115,7 @@ function clean() {
if [[ $? == 0 ]]; then
COUNTER=0
# some resources (e.g. boot volumes) are deleted with some delay. Hence, the script waits before exiting with an error
while [[ "$(ibmcloud resource service-instances --type all -g $resource_group_name --output json | jq -r '. | length')" != "0" ]]; do
while (( "$(ibmcloud resource service-instances --type all -g $resource_group_name --output json | jq -r '. | length')" > 0 )); do
sleep 5
COUNTER=$((COUNTER + 1))
if ((COUNTER > 30)); then
Expand Down Expand Up @@ -185,7 +185,7 @@ ibmcloud target -g $resource_group_name
#
# Create the connector and obtain its identifier
print_msg "\nCreating the Satellite Connector '$sat_connector_name' ..."
ibmcloud sat experimental connector create --name $sat_connector_name --region $REGION
ibmcloud sat connector create --name $sat_connector_name --region $REGION
if [ $? -ne 0 ]; then
print_error "Failed to create the Satellite Connector"
abortScript
Expand Down Expand Up @@ -539,7 +539,7 @@ if [ $? -ne 0 ]; then
fi
print_msg "\nCreating a Code Engine job '$ce_job_name' that will connect to the database ..."
ibmcloud ce job create --name $ce_job_name \
IBMCLOUD_TRACE=true ibmcloud ce job create --name $ce_job_name \
--build-source ./ce-job \
--env-from-secret $ce_db_credentials \
--memory 0.5G \
Expand All @@ -561,8 +561,8 @@ print_msg "\nListing submitted job runs..."
ibmcloud ce jobrun list
print_msg "\nCreating a Code Engine app '$ce_app_name' that retrieve records from the database ..."
ibmcloud ce app create --name $ce_app_name \
--build-source ce-app \
IBMCLOUD_TRACE=true ibmcloud ce app create --name $ce_app_name \
--build-source ./ce-app \
--env-from-secret $ce_db_credentials \
--memory 0.5G \
--cpu 0.25
Expand Down

0 comments on commit 3d070ba

Please sign in to comment.