Skip to content

Commit cd1e003

Browse files
committed
feat(initial): Initial baseline
Signed-off-by: sylus <[email protected]>
1 parent 24e2ce1 commit cd1e003

18 files changed

+265
-214
lines changed

Diff for: .dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
deploy/
21
Dockerfile

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

Diff for: .github/workflows/build.yml

-18
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
1-
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service using a helm chart.
2-
#
3-
# https://github.com/Azure/actions-workflow-samples/tree/master/Kubernetes
4-
#
5-
# To configure this workflow:
6-
#
7-
# 1. Set up the following secrets in your workspace:
8-
# a. REGISTRY_USERNAME with ACR username
9-
# b. REGISTRY_PASSWORD with ACR Password
10-
# c. AZURE_CREDENTIALS with the output of `az ad sp create-for-rbac --sdk-auth`
11-
#
12-
# 2. Change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables (below).
131
name: build
142
on: [pull_request]
153

16-
# Environment variables available to all jobs and steps in this workflow
174
env:
185
REGISTRY_NAME: k8scc01covidacr
19-
CLUSTER_NAME: k8s-cancentral-02-covid-aks
20-
CLUSTER_RESOURCE_GROUP: k8s-cancentral-01-covid-aks
21-
NAMESPACE: web
226

237
jobs:
248
build:
259
runs-on: ubuntu-latest
2610
steps:
2711
- uses: actions/checkout@master
2812

29-
# Container build
3013
- run: |
3114
docker build -f Dockerfile -t ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }} .
3215
33-
# Scan image for vulnerabilities
3416
- uses: Azure/container-scan@v0
3517
with:
3618
image-name: ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}

Diff for: .github/workflows/publish.yml

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,28 @@
1-
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service using a helm chart.
2-
#
3-
# https://github.com/Azure/actions-workflow-samples/tree/master/Kubernetes
4-
#
5-
# To configure this workflow:
6-
#
7-
# 1. Set up the following secrets in your workspace:
8-
# a. REGISTRY_USERNAME with ACR username
9-
# b. REGISTRY_PASSWORD with ACR Password
10-
# c. AZURE_CREDENTIALS with the output of `az ad sp create-for-rbac --sdk-auth`
11-
#
12-
# 2. Change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables (below).
131
name: publish
142
on:
153
push:
164
branches:
17-
- master
5+
- main
186

19-
# Environment variables available to all jobs and steps in this workflow
207
env:
218
REGISTRY_NAME: k8scc01covidacr
22-
CLUSTER_NAME: k8s-cancentral-02-covid-aks
23-
CLUSTER_RESOURCE_GROUP: k8s-cancentral-01-covid-aks
24-
NAMESPACE: web
259

2610
jobs:
2711
build:
2812
runs-on: ubuntu-latest
2913
steps:
3014
- uses: actions/checkout@master
3115

32-
# Connect to Azure Container registry (ACR)
3316
- uses: azure/docker-login@v1
3417
with:
3518
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
3619
username: ${{ secrets.REGISTRY_USERNAME }}
3720
password: ${{ secrets.REGISTRY_PASSWORD }}
3821

39-
# Container build and push to a Azure Container registry (ACR)
4022
- run: |
4123
docker build -f Dockerfile -t ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }} .
4224
docker push ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}
4325
44-
# Scan image for vulnerabilities
4526
- uses: Azure/container-scan@v0
4627
with:
4728
image-name: ${{ env.REGISTRY_NAME }}.azurecr.io/jupyter-apis:${{ github.sha }}

Diff for: .github/workflows/test.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Kubeflow Manifests'
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
env:
12+
K3D_VERSION: 4.4.7
13+
KUBECTL_VERSION: 1.21.2
14+
KUSTOMIZE_VERSION: 4.1.3
15+
16+
jobs:
17+
test:
18+
name: 'Test'
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Gather dependencies
26+
run: |
27+
mkdir -p ${GITHUB_WORKSPACE}/bin/
28+
29+
# install kubectl
30+
curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl -o ${GITHUB_WORKSPACE}/bin/kubectl && chmod +x ${GITHUB_WORKSPACE}/bin/kubectl
31+
32+
# install kustomize
33+
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz -o kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && tar -zxvf kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && chmod +x kustomize && mv kustomize ${GITHUB_WORKSPACE}/bin/kustomize
34+
35+
# install k3d
36+
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=v${K3D_VERSION} bash
37+
38+
# install taskfile
39+
curl -sL https://taskfile.dev/install.sh | sh
40+
41+
# install yq
42+
sudo snap install yq
43+
44+
- name: GitHub Path
45+
run: |
46+
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
47+
48+
- name: Build
49+
run: |
50+
task go:build
51+
52+
- name: Linting
53+
run: |
54+
task check

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
coverage_unit.txt
12
jupyter-apis

Diff for: Dockerfile

+12-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
# Stage 0: UI Build Stage
2-
FROM node:10 as frontend
3-
4-
WORKDIR /app
5-
6-
COPY ./frontend/package*.json /app/
7-
RUN npm install
8-
9-
COPY ./frontend/ /app/
10-
11-
# Build the default frontends
12-
RUN npm run build frontend -- --output-path=./dist/out/default --configuration=production
2+
FROM node:12-buster-slim as frontend
3+
WORKDIR /src
4+
COPY ./jupyter/frontend/package*.json ./
5+
COPY ./jupyter/frontend/tsconfig*.json ./
6+
COPY ./jupyter/frontend/angular.json ./
7+
COPY ./jupyter/frontend/src ./src
8+
ENV NG_CLI_ANALYTICS "ci"
9+
RUN npm ci
10+
COPY --from=frontend-kubeflow-lib /src/dist/kubeflow/ ./node_modules/kubeflow/
11+
RUN npm run build -- --output-path=./dist/default --configuration=production
12+
RUN npm run build -- --output-path=./dist/rok --configuration=rok-prod
1313

1414
# Stage 1: Build with the golang image
15-
FROM golang:1.14-alpine AS backend
16-
17-
# Add git
15+
FROM golang:1.17-alpine AS backend
1816
RUN apk add git
19-
20-
# Set workdir
2117
WORKDIR /go/src/github.com/StatCan/jupyter-apis
22-
23-
# Add dependencies
2418
COPY go.mod .
2519
COPY go.sum .
2620
RUN go mod download
27-
28-
# Build
2921
COPY . .
3022
RUN CGO_ENABLED=0 go install .
3123

Diff for: LICENSE renamed to LICENSE.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
MIT License
22

3-
Copyright (c) Her Majesty the Queen in Right of Canada, as represented by the Minister of Statistics Canada, 2020
3+
Copyright (c) Her Majesty the Queen in Right of Canada, as represented by the
4+
Minister responsible for Statistics Canada, 2022
5+
46
Permission is hereby granted, free of charge, to any person obtaining a copy
57
of this software and associated documentation files (the "Software"), to deal
68
in the Software without restriction, including without limitation the rights

Diff for: Taskfile.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
dotenv: ['.env']
4+
output: prefixed
5+
silent: true
6+
7+
vars:
8+
DEFAULT_GO_PACKAGES:
9+
sh: |
10+
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go package(s)"')
11+
LDFLAGS:
12+
13+
CLUSTER_NAME: jupyter-apis
14+
CONTEXT_NAME: "k3d-{{.CLUSTER_NAME}}"
15+
KUBECTL: "kubectl --context={{.CONTEXT_NAME}}"
16+
KUBEAPPLY: "{{.KUBECTL}} apply"
17+
KUSTOMIZE: "{{.KUBEAPPLY}} --kustomize"
18+
KUBEWAIT: "{{.KUBECTL}} wait"
19+
KUBEWAIT_AVAIL: "{{.KUBEWAIT}} --for=condition=available"
20+
KUBEWAIT_READY: "{{.KUBEWAIT}} --for=condition=ready"
21+
KUBECREATE: "{{.KUBECTL}} create -o yaml --dry-run=client"
22+
23+
TODAY: '{{ now | date "2006-01-02T15:04:05-07:00" }}'
24+
BLACK: \033[:0;30m
25+
RED: \033[:0;31m
26+
GREEN: \033[:0;32m
27+
ORANGE: \033[:0;33m
28+
BLUE: \033[:0;34m
29+
PURPLE: \033[:0;35m
30+
CYAN: \033[:0;36m
31+
LIGHT_GRAY: \033[:0;37m
32+
DARK_GRAY: \033[:1;30m
33+
LIGHT_RED: \033[:1;31m
34+
LIGHT_GREEN: \033[:1;32m
35+
YELLOW: \033[:1;33m
36+
LIGHT_BLUE: \033[:1;34m
37+
LIGHT_PURPLE: \033[:1;35m
38+
LIGHT_CYAN: \033[:1;36m
39+
WHITE: \033[:1;37m
40+
NOCOLOR: \u001b[0m
41+
REVERSED: \u001b[7m
42+
43+
tasks:
44+
default:
45+
prefix: ⚙️
46+
cmds:
47+
- task -l
48+
silent: true
49+
50+
check:
51+
desc: Check for problems associated with the project
52+
deps:
53+
- task: go:lint
54+
- task: go:vet
55+
- task: go:test
56+
57+
format:
58+
desc: Format all files
59+
deps:
60+
- task: go:format
61+
62+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
63+
go:build:
64+
desc: Build the Go code
65+
cmds:
66+
- go build -v {{.LDFLAGS}}
67+
68+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
69+
go:fix:
70+
desc: Modernize usages of outdated APIs
71+
dir: '{{default "./" .GO_MODULE_PATH}}'
72+
cmds:
73+
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
74+
75+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
76+
go:format:
77+
desc: Format Go code
78+
dir: '{{default "./" .GO_MODULE_PATH}}'
79+
cmds:
80+
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
81+
82+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
83+
go:lint:
84+
desc: Lint Go code
85+
dir: '{{default "./" .GO_MODULE_PATH}}'
86+
cmds:
87+
- |
88+
if ! which golint &>/dev/null; then
89+
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
90+
exit 1
91+
fi
92+
- |
93+
golint \
94+
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
95+
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
96+
97+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
98+
go:test:
99+
desc: Run unit tests
100+
dir: '{{default "./" .GO_MODULE_PATH}}'
101+
cmds:
102+
- |
103+
go test \
104+
-v \
105+
-short \
106+
-run '{{default ".*" .GO_TEST_REGEX}}' \
107+
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
108+
-coverprofile=coverage_unit.txt \
109+
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
110+
111+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
112+
go:vet:
113+
desc: Check for errors in Go code
114+
dir: '{{default "./" .GO_MODULE_PATH}}'
115+
cmds:
116+
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
117+
118+
k3d:create:
119+
prefix: ⚙️ > create
120+
desc: create k3d cluster
121+
cmds:
122+
- k3d cluster create --config=cluster/config.yaml
123+
124+
k3d:create:dev:
125+
prefix: ⚙️ > create
126+
desc: create k3d cluster (devcontainers)
127+
deps:
128+
- k3d:create
129+
cmds:
130+
- sed -i -e "s/0.0.0.0/host.docker.internal/g" ${HOME}/.kube/config
131+
132+
k3d:destroy:
133+
prefix: ⚙️ > destroy
134+
desc: destroy k3d cluster
135+
cmds:
136+
- "k3d cluster delete {{.CLUSTER_NAME}}"
137+
138+
k3d:start:
139+
prefix: ⚙️ > start
140+
desc: starts knative environment
141+
cmds:
142+
- "k3d cluster start {{.CLUSTER_NAME}}"
143+
144+
k3d:stop:
145+
prefix: ⚙️ > stop
146+
desc: stop knative environment
147+
cmds:
148+
- "k3d cluster stop {{.CLUSTER_NAME}}"

0 commit comments

Comments
 (0)