Skip to content

Commit

Permalink
fixup!chore(github-action): build cnb image - remove host network, us…
Browse files Browse the repository at this point in the history
…e link instead
  • Loading branch information
o-orand committed Sep 25, 2024
1 parent c0f3a6b commit 4b4ffff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build-using-cnb-buildpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ on:
- "v?[0-9]+.[0-9]+.[0-9]+*"
env:
CNB_IMAGE_NAME: cnb-app
SERVICE_VERSION: '6.0'
SERVICE_PORT: 6379 # Default value: 27017
SERVICE_USERNAME: '22032e25-4aba-417f-a394-8bbd78d920cd'
# SERVICE_VERSION: '6.0'
SERVICE_HOST: redis
SERVICE_PORT: 6379
# SERVICE_USERNAME: '22032e25-4aba-417f-a394-8bbd78d920cd'
SERVICE_PASSWORD: 'StbQ4EovUpwQjD0cT1Hr7PKBG'
DATABASE_NAME: my-redis-db
# DATABASE_NAME: my-redis-db

jobs:
package-app:
name: "Package ${{ github.repository }} as CNB app"
runs-on: ubuntu-latest
services:
redis:
redis-service:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
Expand Down Expand Up @@ -49,8 +50,8 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
# with:
# driver-opts: network=host
-
name: Setup pack for ${{ github.repository }}
uses: buildpacks/github-actions/[email protected]
Expand Down Expand Up @@ -80,7 +81,7 @@ jobs:
cat vcap-services-template.sh|envsubst >vcap-service.env
cat vcap-service.env
echo "Starting sample app"
container_id=$(docker run -d --network host -e PORT=8080 --env-file vcap-service.env --name "cnb-app-container" ${{env.CNB_IMAGE_NAME}})
container_id=$(docker run -d --link redis-service -e PORT=8080 --env-file vcap-service.env --name "cnb-app-container" ${{env.CNB_IMAGE_NAME}})
echo "Cnb app started (id: $container_id)"
docker inspect -f '{{.HostConfig.LogConfig.Type}}' $container_id
# docker run -e PORT=80 --env-file vcap-service.env -p 8080:80 --name "cnb-app-container" ${{env.CNB_IMAGE_NAME}}
Expand Down Expand Up @@ -108,7 +109,7 @@ jobs:
echo "Dumping logs using docker logs cnb-app-container"
docker logs cnb-app-container
ls -lrt
exit $exit_status
#exit $exit_status
-
name: Tag version ${{github.ref_name}}
if: github.ref_type == 'tag'
Expand Down
25 changes: 13 additions & 12 deletions vcap-services-template.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
VCAP_SERVICES='
{
"mongodb-dedicated":[
"redis-dedicated":[
{
"binding_guid":"${SERVICE_USERNAME}",
"binding_guid":"532023be-5847-4dc7-90f4-2f207f2bb440",
"binding_name":null,
"credentials":{
"database":"${DATABASE_NAME}",
"hostname":"localhost:${SERVICE_PORT}",
"host":"${SERVICE_HOST}",
"password":"${SERVICE_PASSWORD}",
"uri":"mongodb://${SERVICE_USERNAME}:${SERVICE_PASSWORD}@localhost:${SERVICE_PORT}/${DATABASE_NAME}?replicaSet=rs0",
"username":"${SERVICE_USERNAME}"
"port":"${SERVICE_PORT}"
},
"instance_guid":"cc252ef5-2541-49fd-8a57-fe73957905a5",
"instance_name":"mongodb-github-test",
"label":"mongodb-dedicated",
"name":"mongodb-github-test",
"instance_guid":"98645cee-2810-408c-abcd-2c2b41fed9aa",
"instance_name":"redis-smoketest-1727200788",
"label":"redis-dedicated",
"name":"redis-smoketest-1727200788",
"plan":"small",
"provider":null,
"syslog_drain_url":null,
"tags":[
"mongodb",
"document"
"Redis",
"Document"
],
"volume_mounts":[]
}
]
}
'

0 comments on commit 4b4ffff

Please sign in to comment.