Skip to content
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

Go development environment for finance added #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/ci-pipeline-go-for-finance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# by-EAjks.Com Development Environments
# Copyright (C) 2022-2024 Andrea and Eric DELAGE <Contact@by-EAjks.Com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

name: (CI/CD) Build and deploy the go-for-finance container images
on:
push:
branches:
- 'main'
- 'feature/go-for-finance/**'
- 'issue/go-for-finance/**'
- 'release/go-for-finance/**'
tags:
- 'go-for-finance-v\d+.\d+.\d+'
paths:
- '.github/workflows/ci-pipeline-go-for-finance.yaml'
- 'DevOps/Docker/Go-For-Finance/**'
env:
IMAGE_REPOSITORY: eajkseajks
jobs:
build-and-push-container-images:
name: Build and push the container images
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
env:
IMAGE_NAME: go-for-finance
steps:
- name: Checkout the git repository
uses: actions/checkout@v4.2.2
# https://github.com/actions/checkout/tags
- name: Install cosign
uses: sigstore/cosign-installer@v3.7.0
with:
cosign-release: v2.4.1
# https://github.com/sigstore/cosign-installer/tags
# https://github.com/sigstore/cosign/releases
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3.7.1
# https://github.com/docker/setup-buildx-action/tags
- name: Login to ${{env.IMAGE_REPOSITORY}} registry
uses: docker/login-action@v3.3.0
with:
registry: docker.io
username: ${{secrets.DOCKER_HUB_USERNAME}}
password: ${{secrets.DOCKER_HUB_ACCESS_TOKEN}}
# https://github.com/docker/login-action/tags
- id: extract-metadata-sdk
name: Extract the ${{env.IMAGE_NAME}}-sdk metadata
uses: docker/metadata-action@v5.5.1
with:
context: workflow
images: |
${{env.IMAGE_REPOSITORY}}/${{env.IMAGE_NAME}}-sdk
flavor: |
latest=false
prefix=,onlatest=true
suffix=,onlatest=true
tags: |
type=match,pattern=\d+.\d+.\d+
type=match,pattern=\d+.\d+
type=match,pattern=\d+
type=ref,event=branch
type=ref,prefix=pr-,event=pr
# https://github.com/docker/metadata-action/tags
- id: build-and-push-sdk
name: Build the ${{env.IMAGE_NAME}}-sdk image and push it to the ${{env.IMAGE_REPOSITORY}} registry
uses: docker/build-push-action@v6.9.0
with:
context: .
file: ./DevOps/Docker/Go-For-Finance/SDK/Dockerfile
tags: ${{steps.extract-metadata-sdk.outputs.tags}}
labels: ${{steps.extract-metadata-sdk.outputs.labels}}
push: true
# https://github.com/docker/build-push-action/tags
- name: Sign the ${{env.IMAGE_NAME}}-sdk image with GitHub OIDC token
env:
TAGS: ${{steps.extract-metadata-sdk.outputs.tags}}
DIGEST: ${{steps.build-and-push-sdk.outputs.digest}}
run: |
for TAG in ${TAGS}; do
cosign sign --yes ${TAG}@${DIGEST}
done
110 changes: 110 additions & 0 deletions DevOps/Docker/Go-For-Finance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Go Development Environment for DMTF Finance and SNIA Swordfish Apps

- [Go Development Environment for DMTF Finance and SNIA Swordfish Apps](#go-development-environment-for-dmtf-finance-and-snia-swordfish-apps)
- [Building, Testing, and Deploying the Container Image](#building-testing-and-deploying-the-container-image)
- [Building in Interactive Mode](#building-in-interactive-mode)
- [On a Linux Host](#on-a-linux-host)
- [On a Windows Host](#on-a-windows-host)
- [In the Linux Guest](#in-the-linux-guest)
- [Building in Batch Mode](#building-in-batch-mode)
- [On a Linux Host](#on-a-linux-host-1)
- [On a Windows Host](#on-a-windows-host-1)

## Building, Testing, and Deploying the Container Image

```powershell
cd /Path/To/Development-Environments
```

### Building in Interactive Mode

#### On a Linux Host

```bash
docker run \
--interactive \
--tty \
--name development-environments-go-for-finance \
--volume '/Path/To/Development-Environments:/src' \
--workdir /build \
docker.io/ubuntu:24.10
```

```bash
docker start --interactive development-environments-go-for-finance
```

#### On a Windows Host

```powershell
docker run `
--interactive `
--tty `
--name development-environments-go-for-finance `
--volume '/Path/To/Development-Environments:/src' `
--workdir /build `
docker.io/ubuntu:24.10
```

```powershell
docker start --interactive development-environments-go-for-finance
```

#### In the Linux Guest

```bash
apt-get update

apt-get install --yes --no-install-recommends \
ca-certificates \
curl

rm -rf /usr/local/go

curl -fsSL https://go.dev/dl/go1.23.3.linux-amd64.tar.gz | tar -xzf - -C /usr/local

apt-get remove --yes --purge \
curl

apt-get autoremove --yes --purge

rm -rf /var/lib/apt/lists/*
```

```bash
export PATH=/usr/local/go/bin${PATH:+:${PATH}}
```

```bash
cd /build
```

```bash
go mod init skeleton
go get github.com/spf13/cobra@v1.8.1
go get github.com/spf13/viper@v1.19.0
go get github.com/go-logr/logr@v1.4.2
go get github.com/go-logr/zerologr@v1.2.3
go get github.com/stmcginnis/gofish@v0.20.0
go mod vendor
```

### Building in Batch Mode

#### On a Linux Host

```bash
docker build \
--file DevOps/Docker/Go-For-Finance/SDK/Dockerfile \
--tag docker.io/eajkseajks/go-for-finance-sdk:0.0.0 \
.
```

#### On a Windows Host

```powershell
docker build `
--file DevOps/Docker/Go-For-Finance/SDK/Dockerfile `
--tag docker.io/eajkseajks/go-for-finance-sdk:0.0.0 `
.
```
63 changes: 63 additions & 0 deletions DevOps/Docker/Go-For-Finance/SDK/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# by-EAjks.Com Development Environments
# Copyright (C) 2022-2024 Andrea and Eric DELAGE <Contact@by-EAjks.Com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

FROM ubuntu:24.10

LABEL maintainer="by-EAjks.Com <Contact@by-EAjks.Com>"

ENV DEBIAN_FRONTEND=noninteractive

# Add Go support

RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /usr/local/go \
&& curl -fsSL https://go.dev/dl/go1.23.3.linux-amd64.tar.gz | tar -xzf - -C /usr/local \
&& apt-get remove --yes --purge \
curl \
&& apt-get autoremove --yes --purge \
&& rm -rf /var/lib/apt/lists/*

ENV PATH=/usr/local/go/bin${PATH:+:${PATH}}

# Add Go modules for Finance apps

WORKDIR /build

RUN go mod init skeleton \
&& go get github.com/spf13/cobra@v1.8.1 \
&& go get github.com/spf13/viper@v1.19.0 \
&& go get github.com/go-logr/logr@v1.4.2 \
&& go get github.com/go-logr/zerologr@v1.2.3 \
&& go get gorm.io/gorm@v1.25.12 \
&& go get gorm.io/driver/sqlite@v1.5.6 \
&& go get gorm.io/driver/mysql@v1.5.7 \
&& go get gorm.io/driver/sqlserver@v1.5.4 \
&& go get github.com/pressly/goose@v2.7.0 \
&& go get gonum.org/v1/gonum@v0.15.1 \
&& go get gonum.org/v1/plot@v0.14.0 \
&& go get gorgonia.org/gorgonia@v0.9.18 \
&& go get github.com/tensorflow/tensorflow/tensorflow/go@v2.18.0 \
&& go mod vendor

# Upgrade the image with the latest patches

RUN apt-get update \
&& apt-get upgrade --yes \
&& apt-get autoremove --yes --purge \
&& rm -rf /var/lib/apt/lists/*