forked from hrbrmstr/pewpew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] helm support, external data source support
- Loading branch information
Showing
18 changed files
with
1,190 additions
and
373 deletions.
There are no files selected for viewing
This file contains 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,77 @@ | ||
# Build and Push Docker Image and Helm Chart Github Action | ||
|
||
This Github Action builds a Docker image from a Dockerfile and pushes it to Docker Hub, GitHub Container Registry, and Jfrog Container Registry, and pushes a deployable Helm Chart to Jfrog Artifactory. | ||
|
||
## Usage | ||
|
||
1. Create a `.github/workflows/docker.yml` file in your Github repository. | ||
1. Copy the contents of this action into the `docker.yml` file. | ||
1. For Jfrog Artifactory, login to your instance and | ||
1. Select `+ Add Repositories` from the `Repositories > Repositories` view. | ||
1. Create a `Local Repository` that will serve as our Artifactory. | ||
1. Select `Helm` as the package type. | ||
1. Set a value for `Repository Key` that will serve as the Artifactory's name. | ||
1. Select your repository from the `Artifactory > Artifacts` view. | ||
1. Your Jfrog fully qualified domain name (e.g; `artifactory.yourcompany.io`) will be your URL (`JFROG_URL` as we'll see in the steps below). | ||
1. Click `+ Generate Token` from the `User Management > Access Tokens` view. | ||
1. Scope permissions for the access token if desired. | ||
1. Click `Generate` and save the generated token. This will be your pipeline's access token (`JFROG_ACCESS_TOKEN` as we'll see in the steps below) | ||
1. For Jfrog Container Registry, login to your instance and | ||
1. Select `+ Add Repositories` from the `Repositories > Repositories` view. | ||
1. Create a `Local Repository` that will serve as our Container Registry. | ||
1. Select `Docker` as the package type. | ||
1. Set a value for `Repository Key`. This will be your repository name (`JFROG_REPOSITORY` as we'll see in the steps below). | ||
1. Select your repository from the `Artifactory > Artifacts` view. | ||
1. Click `Set Me Up` and `Generate token and create instructions`. | ||
1. Save the generated token, this will be your registry password (`JFROG_TOKEN` as we'll see in the steps below). | ||
1. Your Jfrog email will be your username (`JFROG_USERNAME` as we'll see in the steps below). | ||
1. Your Jfrog fully qualified domain name (e.g; `artifactory.yourcompany.io`) will be your registry name (`JFROG_REGISTRY` as we'll see in the steps below). | ||
1. For GitHub Container Registry, login to your GitHub account and | ||
1. Generate a new token from the `Settings > Developer settings > Personal access tokens` view with the following permissions: `read:packages`, `write:packages`, `delete:packages` as well as access to your repo if it is private. | ||
1. Save the generated token, this will be your registry password (`GH_TOKEN` as we'll see in the steps below). | ||
1. For Docker Container Registry, login to your DockerHub account and | ||
1. Select `New Access Token` from the `Settings > Security` view with `read`, `write`, `delete` permissions. | ||
1. Save the generated token, this will be your registry password (`DOCKERHUB_TOKEN` as we'll see in the steps below). | ||
1. Your DockerHub username will be your username (`DOCKERHUB_USERNAME` as we'll see in the steps below). | ||
1. Create secrets for your Docker Hub username and token, your GitHub token, and your Jfrog username, token, registry, and repository. Add these secrets to your repository's secrets. | ||
|
||
```yaml | ||
secrets: | ||
DOCKERHUB_USERNAME: <your_username> | ||
DOCKERHUB_TOKEN: <your_token> | ||
|
||
GH_TOKEN: <your_token> | ||
|
||
JFROG_REGISTRY: <your_registry> | ||
JFROG_USERNAME: <your_username> | ||
JFROG_TOKEN: <your_token> | ||
JFROG_REPOSITORY: <your_repository> | ||
|
||
JFROG_ACCESS_TOKEN: <your_access_token> | ||
JFROG_URL: <your_instance_url> | ||
``` | ||
4. Modify the tags field in the Build and push step to reflect your desired Docker image name and version. | ||
```yaml | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile | ||
push: true | ||
tags: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/sammwise:latest | ||
ghcr.io/${{ github.repository_owner }}/sammwise:latest | ||
${{ secrets.JFROG_REGISTRY }}/${{ secrets.JFROG_REPOSITORY }}/sammwise:latest | ||
``` | ||
## Workflow | ||
1. The workflow is triggered when code is pushed to the main branch, or when it is manually triggered from the Actions tab. | ||
1. The build job is started on an ubuntu-latest runner. | ||
1. The Docker image is built from the Dockerfile located in the ./docker directory. | ||
1. The image is tagged with the specified tags. | ||
1. The Docker image is pushed to Docker Hub and GitHub Container Registry. | ||
## Acknowledgements | ||
This Github Action was adapted from the [Build and Push Docker Image action by Docker](https://github.com/marketplace/actions/build-and-push-docker-images). | ||
This file contains 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,88 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Build and push docker image | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# commented to not be triggered on each commit | ||
# # Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: ["main"] | ||
# pull_request: | ||
# branches: [ "main" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
runs-on: ubuntu-latest | ||
# env: | ||
# JF_URL: ${{ secrets.JFROG_URL }} | ||
# JF_ACCESS_TOKEN: ${{ secrets.JFROG_ACCESS_TOKEN }} | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
# Runs a single command using the runners shell | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
# - name: Login to GitHub Container Registry | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.repository_owner }} | ||
# password: ${{ secrets.GH_TOKEN }} | ||
# - name: Login to Jfrog Container Registry | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: sju.jfrog.io | ||
# username: ${{ secrets.JFROG_USERNAME }} | ||
# password: ${{ secrets.JFROG_TOKEN }} | ||
|
||
- name: Build and push (pewpew) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile | ||
push: true | ||
tags: | | ||
sjultra/pewpew:latest | ||
- name: Build and push (adapter) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./docker/adapter | ||
file: ./docker/adapter/Dockerfile | ||
push: true | ||
tags: | | ||
sjultra/pewpew-adapter:latest | ||
# ghcr.io/${{ github.repository_owner }}/pewpew:latest | ||
# install and authenticate jfrog/artifactory CLI | ||
# - uses: jfrog/[email protected] | ||
# - name: Verify artifactory server connection | ||
# run: jf rt ping | ||
|
||
# - name: Cleanup artifactory | ||
# run: | | ||
# jf rt del "pewpew-helm/*" | ||
|
||
# - name: Distribute source to artifactory | ||
# run: | | ||
# cd ./helm | ||
# tar -cvzf pewpew.tgz ./service/ | ||
# jf rt upload pewpew.tgz pewpew-helm/ | ||
# cd - |
This file contains 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 @@ | ||
node_modules/ |
This file contains 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,22 @@ | ||
--- | ||
version: "1.0" | ||
services: | ||
pewpew: | ||
build: | ||
context: . | ||
dockerfile: ./docker/Dockerfile | ||
volumes: | ||
- ./docker/adapter/data:/opt/pewpew/data | ||
ports: | ||
- 8080:8080 | ||
restart: unless-stopped | ||
# depends_on: | ||
# - "pewpew_data" | ||
|
||
# pewpew_data: | ||
# build: | ||
# context: ./docker/datasource | ||
# dockerfile: ./docker/datasource/Dockerfile | ||
# volumes: | ||
# - ./docker/datasource/data:/datasource/data | ||
# restart: unless-stopped |
This file contains 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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
FROM node:latest | ||
|
||
EXPOSE 8080 | ||
|
||
WORKDIR /opt/pewpew | ||
COPY . /opt/pewpew | ||
RUN npm install http-server -g | ||
RUN mkdir -p /opt/pewpew | ||
|
||
RUN mkdir ./data | ||
VOLUME ./data | ||
|
||
# init external data file | ||
RUN touch ./data/data.json | ||
RUN echo "{\"data\": []}" > ./data/data.json | ||
|
||
CMD ["http-server","-a","0.0.0.0","-p","8080","/opt/pewpew"] | ||
|
This file contains 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,13 @@ | ||
FROM node:latest | ||
|
||
EXPOSE 8090 | ||
WORKDIR /adapter | ||
COPY . . | ||
RUN npm install --include-dev | ||
|
||
VOLUME ./data | ||
ENV TENANT_ID | ||
ENV CLIENT_ID | ||
ENV CLIENT_SECRET | ||
|
||
CMD ["npm","run","trace"] |
This file contains 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 @@ | ||
{"data":[{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.7506,"longitude":-122.4121},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.7506,"longitude":-122.4121},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":30.5875,"longitude":-97.8535},"destination":{"latitude":37.3512,"longitude":-121.8846}}},{"hit":{"origin":{"latitude":37.3083,"longitude":-121.9643},"destination":{"latitude":37.3512,"longitude":-121.8846}}}]} |
Oops, something went wrong.