Skip to content

Commit

Permalink
dapr sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
halokid committed Nov 11, 2022
1 parent b963218 commit e9cdef2
Show file tree
Hide file tree
Showing 525 changed files with 26,507 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dapr/quickstarts/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

FROM mcr.microsoft.com/vscode/devcontainers/universal:latest

# Copy custom first notice message.
COPY first-run-notice.txt /tmp/staging/
RUN sudo mv -f /tmp/staging/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ \
&& sudo rm -rf /tmp/staging

# Install minikube
RUN MINIKUBE_URL="https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64" \
&& sudo curl -sSL -o /usr/local/bin/minikube "${MINIKUBE_URL}" \
&& sudo chmod 0755 /usr/local/bin/minikube \
&& MINIKUBE_SHA256=$(curl -sSL "${MINIKUBE_URL}.sha256") \
&& echo "${MINIKUBE_SHA256} */usr/local/bin/minikube" | sha256sum -c -

# Install Dapr CLI
RUN wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash

# Install mechanical-markdown for quickstart validations
RUN pip install mechanical-markdown
27 changes: 27 additions & 0 deletions dapr/quickstarts/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Dapr Quickstarts Codespace",
"dockerFile": "Dockerfile",
"extensions": [
"golang.go",
"ms-azuretools.vscode-dapr",
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools"
],
"mounts": [
// Mount docker-in-docker library volume
"source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"
],
// Always run image-defined docker-init.sh to enable docker-in-docker
"overrideCommand": false,
"remoteUser": "codespace",
"runArgs": [
// Enable ptrace-based debugging for Go in container
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",

// Enable docker-in-docker configuration
"--init",
"--privileged"
],
}
4 changes: 4 additions & 0 deletions dapr/quickstarts/.devcontainer/first-run-notice.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
👋 Welcome to the Dapr Codespace! You are on our Dapr Quickstarts image.
It includes everything needed to run through our tutorials and quickstart applications.

📚 Dapr docs can be found at: https://docs.dapr.io/
26 changes: 26 additions & 0 deletions dapr/quickstarts/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Report a bug in Dapr quickstarts
title: ''
labels: kind/bug
assignees: ''

---

<!-- Note: this issue queue is for bugs specifically in quickstart tutorials. If you are trying to report a bug with dapr itself please do so here: https://github.com/dapr/dapr/issues/new -->

<!-- If you are just looking for help running the tutorials, you can head over to our community discord for quicker response times: https://aka.ms/dapr-discord -->

## Expected Behavior

<!-- Briefly describe what you expect to happen -->


## Actual Behavior

<!-- Briefly describe what is actually happening -->


## Steps to Reproduce the Problem

<!-- How can a maintainer reproduce this issue (be detailed) -->
12 changes: 12 additions & 0 deletions dapr/quickstarts/.github/ISSUE_TEMPLATE/discussion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Discussion
about: Start a discussion for Dapr quickstarts
title: ''
labels: kind/discussion
assignees: ''

---

<!-- Note: this issue queue is for discussions specifically for quickstart tutorials. If you are trying to have a discussion about dapr itself please create it here: https://github.com/dapr/dapr/issues/new -->

<!-- If you are just looking for help running the tutorials, you can head over to our community discord for quicker response times: https://aka.ms/dapr-discord -->
14 changes: 14 additions & 0 deletions dapr/quickstarts/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature Request
about: Create a Feature Request for Dapr quickstarts
title: ''
labels: kind/enhancement
assignees: ''

---

<!-- Note: this issue queue is for features specifically in quickstart tutorials. If you are trying to request a feature with dapr itself please do so here: https://github.com/dapr/dapr/issues/new -->

<!-- If you are just looking for help running the tutorials, you can head over to our community discord for quicker response times: https://aka.ms/dapr-discord -->

## Describe the feature
14 changes: 14 additions & 0 deletions dapr/quickstarts/.github/ISSUE_TEMPLATE/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Proposal
about: Create a proposal for Dapr quickstarts
title: ''
labels: kind/proposal
assignees: ''

---

<!-- Note: this issue queue is for proposals specifically related quickstart tutorials. If you are trying to propose something for dapr itself please do so here: https://github.com/dapr/dapr/issues/new -->

<!-- If you are just looking for help running the tutorials, you can head over to our community discord for quicker response times: https://aka.ms/dapr-discord -->

## Describe the proposal
14 changes: 14 additions & 0 deletions dapr/quickstarts/.github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Question
about: Ask a question about Dapr quickstarts
title: ''
labels: kind/question
assignees: ''

---

<!-- Note: this issue queue is for questions specifically about quickstart tutorials. If you are trying to ask a question regarding dapr itself please do so here: https://github.com/dapr/dapr/issues/new -->

<!-- If you are just looking for help running the tutorials, you can head over to our community discord for quicker response times: https://aka.ms/dapr-discord -->

## Ask your question here
18 changes: 18 additions & 0 deletions dapr/quickstarts/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Description

_Please explain the changes you've made_

## Issue reference

We strive to have all PRs being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #_[issue number]_

## Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

* [ ] The quickstart code compiles correctly
* [ ] You've tested new builds of the quickstart if you changed quickstart code
* [ ] You've updated the quickstart's README if necessary
* [ ] If you have changed the steps for a quickstart be sure that you have updated the automated validation accordingly. All of our quickstarts have annotations that allow them to be executed automatically as code. For more information see [mechanical-markdown](https://github.com/dapr/mechanical-markdown#readme). For user guide with examples see [Examples](https://github.com/dapr/mechanical-markdown/tree/main/examples#mechanical-markdown-by-example).
39 changes: 39 additions & 0 deletions dapr/quickstarts/.github/scripts/get_release_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# This script parses release version from Git tag and set the parsed version to
# environment variable, REL_VERSION.

import os
import sys

gitRef = os.getenv("GITHUB_REF")
tagRefPrefix = "refs/tags/v"

with open(os.getenv("GITHUB_ENV"), "a") as githubEnv:
if gitRef is None or not gitRef.startswith(tagRefPrefix):
githubEnv.write("REL_VERSION=edge\n")
print ("This is daily build from {}...".format(gitRef))
sys.exit(0)

releaseVersion = gitRef[len(tagRefPrefix):]
releaseNotePath="docs/release_notes/v{}.md".format(releaseVersion)

if gitRef.find("-rc.") > 0:
print ("Release Candidate build from {}...".format(gitRef))
else:
# Set LATEST_RELEASE to true
githubEnv.write("LATEST_RELEASE=true\n")
print ("Release build from {}...".format(gitRef))

githubEnv.write("REL_VERSION={}\n".format(releaseVersion))
177 changes: 177 additions & 0 deletions dapr/quickstarts/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: samples

on:
push:
branches:
- master
- feature/new_quickstarts
- release-*
tags:
- v*
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
TARGET_OS: ${{ matrix.target_os }}
TARGET_ARCH: ${{ matrix.target_arch }}
DOCKER_CLI_EXPERIMENTAL: enabled
strategy:
matrix:
os: [ubuntu-latest]
target_arch: [arm, arm64, amd64]
include:
- os: ubuntu-latest
target_os: linux
exclude:
- os: windows-latest
target_arch: arm
- os: macOS-latest
target_arch: arm
- os: windows-latest
target_arch: arm64
- os: macOS-latest
target_arch: arm64
steps:
- name: Check Docker version
run: docker --version
- name: Check out code
uses: actions/checkout@v2
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Set Docker's multiarch/qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name mybuilder --driver docker-container --use
- name: Check platforms buildx supports
run: docker buildx inspect --bootstrap
- name: Build docker image
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make build
popd
done
- name: docker login
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: publish image to dockerhub
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make push
popd
done
- name: GitHub container registry login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
env:
SAMPLE_REGISTRY: ghcr.io/dapr/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make build
popd
done
- name: publish image to ghcr
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/dapr/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make push
popd
done
publish:
name: Publish docker manifest
needs: build
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: create docker manifest
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make manifest-create
popd
done
- name: docker login
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: publish manifest to dockerhub
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make manifest-push
popd
done
- name: GitHub container registry login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: create ghcr manifest
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/dapr/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make manifest-create
popd
done
- name: publish manifest to ghcr
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/dapr/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make manifest-push
popd
done
Loading

0 comments on commit e9cdef2

Please sign in to comment.