-
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.
Merge pull request #5 from xtuml/3-merge-smartdcsit-http-server-repo
3 merge smartdcsit http server repo
- Loading branch information
Showing
38 changed files
with
1,971 additions
and
0 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,31 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/go:1": { | ||
"version": "1.20" | ||
}, | ||
"ghcr.io/eitsupi/devcontainer-features/jq-likes:1": { | ||
"jqVersion": "os-provided", | ||
"yqVersion": "latest", | ||
"gojqVersion": "latest" | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "sudo mkdir /data;sudo chmod a+rw /data; cp -r ${containerWorkspaceFolder}/data/* /data/." | ||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,17 @@ | ||
ARG GO_VERSION=1.20.4 | ||
ARG ALPINE_VERSION=3.16 | ||
|
||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=1000 | ||
|
||
# Setup user | ||
RUN adduser $USERNAME -s /bin/sh -D -u $USER_UID $USER_GID && \ | ||
mkdir -p /etc/sudoers.d && \ | ||
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \ | ||
chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
# Install packages and Go language server | ||
RUN apk add -q --update --progress --no-cache git sudo openssh-client zsh | ||
RUN go get -u -v golang.org/x/tools/cmd/gopls 2>&1 |
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,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gomod | ||
directory: / | ||
schedule: | ||
interval: weekly | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: weekly |
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,46 @@ | ||
name: Push to Container Registry | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
IMAGE_NAME: protocol-verifier-http-server | ||
DOCKERFILE_PATH: ./Dockerfile | ||
|
||
jobs: | ||
build-and-push: | ||
if: github.repository == 'SmartDCSITlimited/protocol-verifier-http-server' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set lowercase image name | ||
run: echo "repository_lowercase=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ env.repository_lowercase }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ${{ env.DOCKERFILE_PATH }} | ||
push: true | ||
# tags: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,74 @@ | ||
variables: | ||
GL_GOLANG_VERSION: 1.20.4 | ||
|
||
cache: | ||
paths: | ||
- /apt-cache | ||
- /go/src/github.com | ||
- /go/src/golang.org | ||
- /go/src/google.golang.org | ||
- /go/src/gopkg.in | ||
|
||
stages: | ||
- test | ||
- build | ||
- push | ||
|
||
include: | ||
- template: Security/SAST.gitlab-ci.yml | ||
|
||
sast: | ||
stage: test | ||
|
||
.go_before_script: | ||
before_script: | ||
- mkdir -p /go/src/gitlab.com/${CI_PROJECT_PATH} /go/src/_/builds | ||
- cp -r $CI_PROJECT_DIR /go/src/gitlab.com/CI_PROJECT_PATH | ||
- ln -s /go/src/gitlab.com/${CI_PROJECT_PATH} /go/src/_/builds/${CI_PROJECT_NAME} | ||
- make dep | ||
|
||
# unit_tests: | ||
# image: golang:${GL_GOLANG_VERSION} | ||
# extends: | ||
# - .go_before_script | ||
# stage: test | ||
# script: | ||
# - make test | ||
|
||
# lint_code: | ||
# image: golang:${GL_GOLANG_VERSION} | ||
# extends: | ||
# - .go_before_script | ||
# stage: test | ||
# script: | ||
# - go get -u golang.org/x/lint/golint | ||
# - make lint | ||
|
||
build: | ||
image: golang:${GL_GOLANG_VERSION} | ||
extends: | ||
- .go_before_script | ||
stage: build | ||
script: | ||
- make build | ||
- ls | ||
artifacts: | ||
when: on_success | ||
paths: | ||
- protocol-verifier-http-server | ||
expire_in: "1 days" | ||
rules: | ||
- if: $CI_COMMIT_TAG | ||
|
||
push: | ||
stage: push | ||
image: | ||
name: gcr.io/kaniko-project/executor:v1.9.0-debug | ||
entrypoint: [""] | ||
script: | ||
- /kaniko/executor | ||
--context "${CI_PROJECT_DIR}" | ||
--dockerfile "${CI_PROJECT_DIR}/Dockerfile" | ||
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" | ||
rules: | ||
- if: $CI_COMMIT_TAG |
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,24 @@ | ||
# first stage to build the go binary | ||
FROM golang:bullseye as firstStage | ||
RUN apt-get update && apt-get -y install make | ||
RUN mkdir /tmp/http_server | ||
WORKDIR /tmp/http_server | ||
COPY . /tmp/http_server/ | ||
RUN make dep && make build | ||
|
||
# second stage to build the app | ||
FROM ubuntu:latest | ||
|
||
RUN mkdir -p /server/{bin,templates} | ||
RUN mkdir -p /data/{aeo_svdc_config/job_definitions,aerconfig,events,logs/verifier,logs/reception,verifier_processed,verifier_incoming,invariant_store,job_id_store} | ||
|
||
COPY --from=firstStage /tmp/http_server/protocol-verifier-http-server /server/bin/protocol-verifier-http-server | ||
WORKDIR /server | ||
RUN chmod +x /server/bin/protocol-verifier-http-server | ||
COPY /templates/index.html /server/templates/index.html | ||
|
||
EXPOSE 9000 | ||
|
||
ENV PATH=$PATH:/server/bin | ||
|
||
ENTRYPOINT ["protocol-verifier-http-server"] |
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,21 @@ | ||
PROJECT_NAME := "protocol-verifier-http-server" | ||
PKG := gitlab.com/smartdcs1/cdsdt/$(PROJECT_NAME) | ||
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) | ||
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go) | ||
|
||
.PHONY: all dep build #test lint | ||
|
||
# lint: ## Lint the files | ||
# @golint -set_exit_status ./... | ||
|
||
# test: ## Run unittests | ||
# @go test -short ${PKG_LIST} | ||
|
||
dep: ## Get the dependencies | ||
@go get -v -d ./... | ||
|
||
build: dep ## Build the binary file | ||
@go build -v $(PKG) | ||
|
||
help: ## Display this help screen | ||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
Oops, something went wrong.