Skip to content

Commit

Permalink
Merge pull request #163 from fabiocicerchia/upgrading
Browse files Browse the repository at this point in the history
Massive functionalities upgrade
  • Loading branch information
fabiocicerchia authored Nov 30, 2023
2 parents 9b1fa5b + 33d3629 commit 1bba5de
Show file tree
Hide file tree
Showing 70 changed files with 8,818 additions and 1,776 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
file: ./docker/Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/go-proxy-cache:latest

Expand All @@ -44,7 +44,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
file: ./docker/Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/go-proxy-cache:${{ github.event.release.tag_name }}

Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ jobs:
image: jaegertracing/all-in-one:1.32.0
node:
image: fabiocicerchia/go-proxy-cache-test:node
#image: fabiocicerchia/npm-start:latest
ports:
- "9001:9001" # ws
- "9002:9002" # wss
#options: >-
# -w /home/node/app
# -v ${{ github.workspace }}/test/full-setup:/home/node/app
collector:
image: otel/opentelemetry-collector:0.35.0
options: >-
-v ${{ github.workspace }}/collector:/etc/otel
# TODO: NEED TO FIND A WAY TO MAKE IT WORKING WITH VOLUMES
nginx:
image: fabiocicerchia/go-proxy-cache-test:nginx
ports:
Expand All @@ -42,25 +48,42 @@ jobs:
options: >-
--link node
--link jaeger
--health-cmd "echo OK"
# -v ${{ github.workspace }}/test/full-setup/nginx:/etc/nginx/conf.d
# -v ${{ github.workspace }}/test/full-setup/certs:/certs
steps:
- uses: actions/checkout@v2

- name: Service Logs - jaeger
uses: docker://docker
with:
args: docker logs "${{ job.services.jaeger.id }}"

# Ref: https://github.community/t/services-and-volumes/16313
- name: Restart node
uses: docker://docker
with:
args: docker restart "${{ job.services.nginx.id }}"

- name: Service Logs - node
uses: docker://docker
with:
args: docker logs "${{ job.services.node.id }}"

# Ref: https://github.community/t/services-and-volumes/16313
- name: Restart collector
uses: docker://docker
with:
args: docker restart "${{ job.services.collector.id }}"
- name: Service Logs - collector
uses: docker://docker
with:
args: docker logs "${{ job.services.collector.id }}"

# Ref: https://github.community/t/services-and-volumes/16313
- name: Restart nginx
uses: docker://docker
with:
args: docker restart "${{ job.services.nginx.id }}"

- name: Service Logs - nginx
uses: docker://docker
with:
Expand Down
33 changes: 29 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,37 @@ changelog: .install-changelog ## generate a changelog

release: ## release
cat main.go | sed "s/const AppVersion = .*/const AppVersion = \"$$VER\"/" | tee main.go
cat main.go | sed "s/const GitCommit = .*/const GitCommit = \"$(shell git rev-parse --short HEAD)\"/" | tee main.go
make changelog
git add CHANGELOG.md
git commit -m "updated changelog for v$$VER"
git tag -af v$$VER -m "Release v$$VER"

docker-push: ## build and push a docker image
docker build -t fabiocicerchia/go-proxy-cache:latest -t fabiocicerchia/go-proxy-cache:$$VER .
docker push fabiocicerchia/go-proxy-cache:latest
docker push fabiocicerchia/go-proxy-cache:$$VER
################################################################################
##@ DOCKER
################################################################################

docker-push-all: ## build and push multiple docker images for multiarch
PLATFORM=amd64 make docker-push-arch
PLATFORM=arm64 make docker-push-arch

docker-push-arch: docker-push ## build and push multiple docker images for one platform
docker buildx build --push --platform=$$PLATFORM -t fabiocicerchia/go-proxy-cache:$$VER-alpine-$$PLATFORM -t fabiocicerchia/go-proxy-cache:alpine-$$PLATFORM -f docker/Dockerfile.alpine .
docker buildx build --push --platform=$$PLATFORM -t fabiocicerchia/go-proxy-cache:$$VER-amazonlinux-$$PLATFORM -t fabiocicerchia/go-proxy-cache:amazonlinux-$$PLATFORM -f docker/Dockerfile.amazonlinux .
docker buildx build --push --platform=$$PLATFORM -t fabiocicerchia/go-proxy-cache:$$VER-debian-$$PLATFORM -t fabiocicerchia/go-proxy-cache:debian-$$PLATFORM -f docker/Dockerfile.debian .
docker buildx build --push --platform=$$PLATFORM -t fabiocicerchia/go-proxy-cache:$$VER-fedora-$$PLATFORM -t fabiocicerchia/go-proxy-cache:fedora-$$PLATFORM -f docker/Dockerfile.fedora .
docker buildx build --push --platform=$$PLATFORM -t fabiocicerchia/go-proxy-cache:$$VER-ubuntu-$$PLATFORM -t fabiocicerchia/go-proxy-cache:ubuntu-$$PLATFORM -f docker/Dockerfile.ubuntu .

################################################################################
##@ HELM
################################################################################

helm-create-package: ## create an helm package from current chart
helm package -d kubernetes/helm/charts kubernetes/helm/

helm-update-repo: ## update index chart repo
helm repo index kubernetes/helm/

helm-deploy-chart: ## deploy to a new helm chart's package
export DEPLOY_FILEPATH=kubernetes/helm/charts/$$DEPLOY_FILE
echo "Manually push the file $$DEPLOY_FILEPATH to GitHub"
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package config
import (
"crypto/tls"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -48,7 +47,7 @@ func newFromEnv() Configuration {
func getFromYaml(file string) (Configuration, error) {
YamlConfig := Configuration{}

data, err := ioutil.ReadFile(filepath.Clean(file))
data, err := os.ReadFile(filepath.Clean(file))
if err != nil {
return YamlConfig, err
}
Expand Down Expand Up @@ -208,6 +207,7 @@ func (c *Configuration) copyOverWithCache(overrides Cache) {
func (c *Configuration) copyOverWithTracing(overrides Tracing) {
c.Tracing.JaegerEndpoint = utils.Coalesce(overrides.JaegerEndpoint, c.Tracing.JaegerEndpoint).(string)
c.Tracing.Enabled = utils.Coalesce(overrides.Enabled, c.Tracing.Enabled).(bool)
// TODO: when starting is not using the default value set in the tag. it might happen to other properties as well.
c.Tracing.SamplingRatio = utils.Coalesce(overrides.SamplingRatio, c.Tracing.SamplingRatio).(float64)
}

Expand Down
2 changes: 2 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
../.github
../vendor
1 change: 1 addition & 0 deletions docker/Dockerfile
5 changes: 5 additions & 0 deletions Dockerfile → docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ WORKDIR /app
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/go-proxy-cache /usr/local/bin/
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/config.yml.dist /app/config.yml

RUN apk upgrade

RUN go-proxy-cache --version \
&& go-proxy-cache --test

CMD ["go-proxy-cache"]
41 changes: 41 additions & 0 deletions docker/Dockerfile.amazonlinux
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# __
# .-----.-----.______.-----.----.-----.--.--.--.--.______.----.---.-.----| |--.-----.
# | _ | _ |______| _ | _| _ |_ _| | |______| __| _ | __| | -__|
# |___ |_____| | __|__| |_____|__.__|___ | |____|___._|____|__|__|_____|
# |_____| |__| |_____|
#
# Copyright (c) 2022 Fabio Cicerchia. https://fabiocicerchia.it. MIT License
# Repo: https://github.com/fabiocicerchia/go-proxy-cache

FROM amazonlinux:2.0.20220316.0 AS builder

ARG BUILD_CMD=build

WORKDIR /go/src/github.com/fabiocicerchia/go-proxy-cache

ENV CGO_CFLAGS -march=native -O3
ENV PATH=/usr/local/go/bin:$PATH

RUN yum install -y \
gcc \
go \
make

COPY . ./

RUN make $BUILD_CMD

FROM amazonlinux:2.0.20220316.0

WORKDIR /app

COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/go-proxy-cache /usr/local/bin/
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/config.yml.dist /app/config.yml

RUN yum install -y glibc-devel \
&& yum upgrade -y

RUN go-proxy-cache --version \
&& go-proxy-cache --test

CMD ["go-proxy-cache"]
35 changes: 35 additions & 0 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# __
# .-----.-----.______.-----.----.-----.--.--.--.--.______.----.---.-.----| |--.-----.
# | _ | _ |______| _ | _| _ |_ _| | |______| __| _ | __| | -__|
# |___ |_____| | __|__| |_____|__.__|___ | |____|___._|____|__|__|_____|
# |_____| |__| |_____|
#
# Copyright (c) 2022 Fabio Cicerchia. https://fabiocicerchia.it. MIT License
# Repo: https://github.com/fabiocicerchia/go-proxy-cache

FROM golang:1.19.5-bullseye AS builder

ARG BUILD_CMD=build

WORKDIR /go/src/github.com/fabiocicerchia/go-proxy-cache

ENV CGO_CFLAGS -march=native -O3

COPY . ./

RUN make $BUILD_CMD

FROM debian:bullseye-20230109-slim

WORKDIR /app

COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/go-proxy-cache /usr/local/bin/
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/config.yml.dist /app/config.yml

RUN apt-get update \
&& apt-get upgrade -y

RUN go-proxy-cache --version \
&& go-proxy-cache --test

CMD ["go-proxy-cache"]
41 changes: 41 additions & 0 deletions docker/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# __
# .-----.-----.______.-----.----.-----.--.--.--.--.______.----.---.-.----| |--.-----.
# | _ | _ |______| _ | _| _ |_ _| | |______| __| _ | __| | -__|
# |___ |_____| | __|__| |_____|__.__|___ | |____|___._|____|__|__|_____|
# |_____| |__| |_____|
#
# Copyright (c) 2022 Fabio Cicerchia. https://fabiocicerchia.it. MIT License
# Repo: https://github.com/fabiocicerchia/go-proxy-cache

FROM fedora:35 AS builder

ARG BUILD_CMD=build

WORKDIR /go/src/github.com/fabiocicerchia/go-proxy-cache

ENV CGO_CFLAGS -march=native -O3
ENV PATH=/usr/local/go/bin:$PATH

RUN yum install -y \
gcc \
go \
make

COPY . ./

RUN make $BUILD_CMD

FROM fedora:35

WORKDIR /app

COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/go-proxy-cache /usr/local/bin/
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/config.yml.dist /app/config.yml

RUN yum install -y glibc-devel \
&& yum upgrade -y

RUN go-proxy-cache --version \
&& go-proxy-cache --test

CMD ["go-proxy-cache"]
45 changes: 45 additions & 0 deletions docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# __
# .-----.-----.______.-----.----.-----.--.--.--.--.______.----.---.-.----| |--.-----.
# | _ | _ |______| _ | _| _ |_ _| | |______| __| _ | __| | -__|
# |___ |_____| | __|__| |_____|__.__|___ | |____|___._|____|__|__|_____|
# |_____| |__| |_____|
#
# Copyright (c) 2022 Fabio Cicerchia. https://fabiocicerchia.it. MIT License
# Repo: https://github.com/fabiocicerchia/go-proxy-cache

FROM ubuntu:21.10 AS builder

ARG BUILD_CMD=build

WORKDIR /go/src/github.com/fabiocicerchia/go-proxy-cache

ENV CGO_CFLAGS -march=native -O3
ENV PATH=/usr/local/go/bin:$PATH

RUN apt update \
&& apt install -y \
gcc \
make \
wget

RUN wget https://go.dev/dl/go1.18.linux-$(dpkg --print-architecture).tar.gz \
&& tar -C /usr/local -xzf go1.18.linux-$(dpkg --print-architecture).tar.gz

COPY . ./

RUN make $BUILD_CMD

FROM ubuntu:21.10

WORKDIR /app

COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/go-proxy-cache /usr/local/bin/
COPY --from=builder /go/src/github.com/fabiocicerchia/go-proxy-cache/config.yml.dist /app/config.yml

RUN apt-get update \
&& apt-get upgrade -y

RUN go-proxy-cache --version \
&& go-proxy-cache --test

CMD ["go-proxy-cache"]
34 changes: 34 additions & 0 deletions docs/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,37 @@ Launch wrk then:
```console
$ lsof -p PID | wc -l
```

## Helm

### Test chart locally

```console
helm install --dry-run --debug --create-namespace -n gpc-test gpc-test ./kubernetes/helm/
```

### Test chart remotely

```console
helm repo update
helm repo add go-proxy-cache-helm https://fabiocicerchia.jfrog.io/artifactory/api/helm/go-proxy-cache-ee-helm --username $USERNAME --password $PASSWORD
helm install --dry-run --debug --create-namespace -n gpc-test gpc-test go-proxy-cache-helm/go-proxy-cache
```

### Uninstall

```console
helm uninstall -n gpc-test gpc-test
```

### Update repo index

```console
make helm-update-repo
```

### Package chart

```console
make helm-create-package
```
2 changes: 1 addition & 1 deletion docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In the folder `test/full-setup` there is complete working environment in Docker:
- Redis
- Nginx (for upstream)
- NodeJS (for ws/wss server)
- Jaeger (for OpenTracing)
- Jaeger (for OpenTelemetry)
- Prometheus (for pulling metrics)
- Grafana (for visualising metrics)

Expand Down
16 changes: 16 additions & 0 deletions docs/KUBERNETES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Kubernetes

## Helm Chart

Create a `values.yaml` from the [default one](kuberneters/helm/values.yaml).

```console
$ helm install --create-namespace -n gpc-test gpc-test -f values.yaml ./kubernetes/helm/
```

## Kustomize

```console
$ kubectl apply -k ./kubernetes/kustomize
```

## Manifest Example

```console
$ kubectl apply -f test/full-setup/kubernetes/k8s.yml
service/go-proxy-cache created
Expand Down
Loading

0 comments on commit 1bba5de

Please sign in to comment.