-
Notifications
You must be signed in to change notification settings - Fork 0
create docker image with cloud server #113
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dcbe45a
create docker image with cloud server
jkralik 77d3ba1
fix ui_file
jkralik e3bcc1c
fetch tags
jkralik f11acdf
fix builds
jkralik 36950af
fix security issue
jkralik 0d3c96d
add README.md
jkralik de20aca
must run under root for update time
jkralik fb11507
fixes
jkralik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Build and publish image | ||
| on: | ||
| push: | ||
| tags: | ||
| - "*" | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
|
|
||
|
|
||
| jobs: | ||
| build-and-publish-image: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
| submodules: recursive | ||
| - name: build-web | ||
| run: | | ||
| mkdir -p `pwd`/.tmp | ||
| make build-web UI_FILE=`pwd`/.tmp/ui.tar.gz | ||
| - uses: docker/setup-qemu-action@v2 | ||
| - uses: docker/setup-buildx-action@v2 | ||
| - uses: docker/login-action@v2 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata (tags, labels) for docker image | ||
| id: meta | ||
| uses: docker/metadata-action@v4 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ github.repository }} | ||
| tags: | | ||
| type=raw,enable={{is_default_branch}},value=vnext | ||
| type=sha,enable={{is_default_branch}},prefix=vnext-,format=short | ||
| type=ref,event=pr,prefix=vnext-pr,suffix=-{{sha}} | ||
| type=ref,event=pr,prefix=vnext-pr | ||
| type=ref,enable={{is_default_branch}},event=branch | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=semver,pattern={{major}} | ||
| - name: Build and publish image | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| context: . | ||
| file: ./docker/Dockerfile | ||
| platforms: linux/amd64,linux/arm64 | ||
| builder: ${{ steps.buildx.outputs.name }} | ||
| build-args: | | ||
| UI_FILE=.tmp/ui.tar.gz | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Clean up | ||
| if: ${{ always() }} | ||
| run: | | ||
| shopt -s dotglob | ||
| sudo rm -r * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Delete old ghcr images | ||
| on: | ||
| schedule: | ||
| - cron: "15 1 * * *" # every day at 1:15am | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| jobs: | ||
| pull-request-ghcr-cleanup: | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| name: Delete images related to closed PR | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Delete images related to closed PR | ||
| uses: snok/container-retention-policy@v1 | ||
| with: | ||
| image-names: client-application | ||
| cut-off: now UTC | ||
| account-type: org | ||
| org-name: plgd-dev | ||
| filter-tags: vnext-pr${{ github.event.pull_request.number }}* | ||
| token: ${{ secrets.GHCR_CLEANUP_PAT }} | ||
| nightly-ghcr-cleanup: | ||
| if: ${{ github.event_name == 'schedule' }} | ||
| name: Delete old vnext images | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Delete older than a month vnext images | ||
| uses: snok/container-retention-policy@v1 | ||
| with: | ||
| image-names: client-application | ||
| cut-off: One month ago UTC | ||
| account-type: org | ||
| org-name: plgd-dev | ||
| filter-tags: vnext-* | ||
| skip-tags: vnext-pr*, main | ||
| token: ${{ secrets.GHCR_CLEANUP_PAT }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM goreleaser/goreleaser AS builder | ||
| ARG UI_FILE | ||
|
|
||
| RUN apk add upx | ||
| WORKDIR /go/src/github.com/plgd-dev/client-application | ||
| COPY go.mod go.sum ./ | ||
| COPY ${UI_FILE} ${UI_FILE} | ||
| COPY . . | ||
| RUN make build BUILD_UI=false UI_FILE=${UI_FILE} | ||
|
|
||
| FROM ghcr.io/iotivity/iotivity-lite/cloud-server-discovery-resource-observable:latest AS service | ||
| COPY ./docker/run.sh /usr/local/bin/run.sh | ||
| COPY --from=builder /go/src/github.com/plgd-dev/client-application/.tmp/dist/*/client-application /usr/local/bin/client-application | ||
| RUN mkdir -p /plgd | ||
| WORKDIR /plgd | ||
| ENTRYPOINT [ "/usr/local/bin/run.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| PREFIX_EXEC="" | ||
| echo Spawning $NUM_DEVICES devices | ||
|
|
||
| umask 0000 | ||
| pids=() | ||
| for ((i=0;i<$NUM_DEVICES;i++)); do | ||
| LD_PRELOAD=/usr/local/lib/faketime/libfaketimeMT.so.1 /iotivity-lite/port/linux/service "device-$i" > /tmp/$i.log 2>&1 & | ||
| pids+=($!) | ||
| done | ||
|
|
||
| /usr/local/bin/client-application --config /plgd/config.yaml $@ > /tmp/client-application.log 2>&1 & | ||
| pids+=($!) | ||
|
|
||
| terminate() | ||
| { | ||
| echo "Terminate" | ||
| for (( i=0; i<${#pids[@]}; i++ )); do | ||
| kill -SIGTERM ${pids[$i]} | ||
| done | ||
| } | ||
|
|
||
| trap terminate SIGTERM | ||
|
|
||
| # Naive check runs checks once a minute to see if either of the processes exited. | ||
| # This illustrates part of the heavy lifting you need to do if you want to run | ||
| # more than one service in a container. The container exits with an error | ||
| # if it detects that either of the processes has exited. | ||
| # Otherwise it loops forever, waking up every 60 seconds | ||
| while sleep 10; do | ||
| for (( i=0; i<${#pids[@]}; i++ )); | ||
| do | ||
| if ! kill -0 ${pids[$i]} 2>/dev/null; then | ||
| echo "service[$i] with pid=${pids[$i]} is dead" | ||
| exit 1 | ||
| fi | ||
| done | ||
| echo checking running devices | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.