Skip to content

Commit

Permalink
Merge pull request #26 from odigos-io/fix/deps
Browse files Browse the repository at this point in the history
feat: build pricing for arm
  • Loading branch information
blumamir authored Jun 25, 2024
2 parents 72217a3 + 01f8bbe commit 13aeb95
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 159 deletions.
184 changes: 35 additions & 149 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: echo "TAG=${GITHUB_REF##refs/*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
steps:

- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: echo "TAG=${GITHUB_REF##refs/*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -93,160 +93,45 @@ jobs:
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_API_TOKEN: ${{ secrets.FURY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
######################
#### FRONTEND ####
######################
frontend:
runs-on:
labels: ubuntu-latest
steps:

- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.TAG }}

- name: Install GemFury CLI
run: |
sudo bash -c "echo 'deb [trusted=yes] https://apt.fury.io/cli/ * *' > /etc/apt/sources.list.d/fury-cli.list"
sudo apt-get update
sudo apt-get install -y fury-cli
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

- name: Release
working-directory: frontend
env:
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_API_TOKEN: ${{ secrets.FURY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t frontend .
docker cp $(docker create --name tc frontend):/app ./dist && docker rm tc
sed -i -E 's/version: .*$/version: '"${TAG}"'/' nfpm.yaml
nfpm pkg --packager rpm --target dist/
nfpm pkg --packager deb --target dist/
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.rpm
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.deb
######################
#### INVENTORY ####
######################
inventory:
runs-on:
labels: ubuntu-latest
steps:

- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.TAG }}

- name: Install GemFury CLI
run: |
sudo bash -c "echo 'deb [trusted=yes] https://apt.fury.io/cli/ * *' > /etc/apt/sources.list.d/fury-cli.list"
sudo apt-get update
sudo apt-get install -y fury-cli
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

- name: Release
working-directory: inventory
env:
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_API_TOKEN: ${{ secrets.FURY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t inventory .
docker create --name tc inventory
mkdir -p ./dist/app
docker cp tc:/app ./dist/app
docker cp tc:/usr/local/lib/python3.11/site-packages ./dist/app/site-packages
docker rm tc
sed -i -E 's/version: .*$/version: '"${TAG}"'/' nfpm.yaml
nfpm pkg --packager rpm --target dist/
nfpm pkg --packager deb --target dist/
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.rpm
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.deb
######################
#### COUPON ####
######################
coupon:
##############################
#### Linux pkg via NPFM ####
##############################
linux-pkg:
strategy:
matrix:
include:
- service: frontend
arch: amd64
pkg_arch: all
- service: inventory
arch: amd64
pkg_arch: all
- service: coupon
arch: amd64
pkg_arch: all
- service: pricing
arch: amd64
pkg_arch: amd64
- service: pricing
arch: arm64
pkg_arch: arm64
runs-on:
labels: ubuntu-latest
steps:

- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: echo "TAG=${GITHUB_REF##refs/*/}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.TAG }}

- name: Install GemFury CLI
run: |
sudo bash -c "echo 'deb [trusted=yes] https://apt.fury.io/cli/ * *' > /etc/apt/sources.list.d/fury-cli.list"
sudo apt-get update
sudo apt-get install -y fury-cli
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

- name: Release
working-directory: coupon
env:
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_API_TOKEN: ${{ secrets.FURY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t coupon .
docker create --name tc coupon
mkdir -p ./dist/app
docker cp tc:/app ./dist/app
docker rm tc
sed -i -E 's/version: .*$/version: '"${TAG}"'/' nfpm.yaml
nfpm pkg --packager rpm --target dist/
nfpm pkg --packager deb --target dist/
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.rpm
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.deb
######################
#### PRICING ####
######################
pricing:
runs-on:
labels: ubuntu-latest
steps:

- name: Store new version in env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.TAG }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Install GemFury CLI
run: |
Expand All @@ -263,18 +148,19 @@ jobs:
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

- name: Release
working-directory: pricing
working-directory: ${{ matrix.service }}
env:
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_API_TOKEN: ${{ secrets.FURY_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t pricing .
docker create --name tc pricing
mkdir -p ./dist/app
docker cp tc:/app ./dist/app
docker buildx build --load --platform=linux/${{ matrix.arch }} -t ${{ matrix.service }} .
docker create --name tc ${{ matrix.service }}
mkdir -p ./dist
sh ./distribution/copy-assets.sh
docker rm tc
sed -i -E 's/version: .*$/version: '"${TAG}"'/' nfpm.yaml
sed -i -E 's/arch: .*$/arch: '"${{ matrix.pkg_arch }}"'/' nfpm.yaml
nfpm pkg --packager rpm --target dist/
nfpm pkg --packager deb --target dist/
fury push --public --account $FURY_ACCOUNT --api-token $FURY_API_TOKEN dist/*.rpm
Expand Down
7 changes: 7 additions & 0 deletions coupon/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distribution
dist
deployment
Dockerfile
.dockerignore
.gitignore
nfpm.yaml
1 change: 1 addition & 0 deletions coupon/distribution/copy-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker cp tc:/app ./dist/app
2 changes: 1 addition & 1 deletion coupon/distribution/systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Odigos Demo Coupon Service
After=network.target

[Service]
ExecStart=node /opt/odigos-demo-coupon/app/app.js
ExecStart=node /opt/odigos-demo-coupon/app.js
KillMode=mixed
Restart=on-failure
RestartSec=1s
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine as fe-build
FROM node:20-alpine AS fe-build
USER node
WORKDIR /home/node
COPY webapp/package* webapp/yarn.lock /home/node/
Expand Down
1 change: 1 addition & 0 deletions frontend/distribution/copy-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker cp tc:/app ./dist
2 changes: 1 addition & 1 deletion frontend/distribution/systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Odigos Demo Frontend Service
After=network.target

[Service]
ExecStart=java -jar /usr/share/java/odigos-demo-frontend.jar
ExecStart=java -jar /opt/odigos-demo-frontend/frontend.jar
KillMode=mixed
Restart=on-failure
RestartSec=1s
Expand Down
4 changes: 2 additions & 2 deletions frontend/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ homepage: https://odigos.io
contents:
- src: distribution/systemd.service
dst: /lib/systemd/system/odigos-demo-frontend.service
- src: ./dist/frontend.jar
dst: /usr/share/java/odigos-demo-frontend.jar
- src: ./dist/app
dst: /opt/odigos-demo-frontend
scripts:
preinstall: ./distribution/preinstall.sh
postinstall: ./distribution/postinstall.sh
Expand Down
2 changes: 1 addition & 1 deletion inventory/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Build Stage
FROM python:3.11 as builder
FROM python:3.11 AS builder

# Set environment variables for Python and prevent writing .pyc files
ENV PYTHONDONTWRITEBYTECODE 1
Expand Down
2 changes: 2 additions & 0 deletions inventory/distribution/copy-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker cp tc:/app ./dist/app
docker cp tc:/usr/local/lib/python3.11/site-packages ./dist/app/site-packages
2 changes: 1 addition & 1 deletion inventory/distribution/systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Odigos Demo Inventory Service
After=network.target

[Service]
ExecStart=python3.11 /opt/odigos-demo-inventory/app/main.py
ExecStart=python3 /opt/odigos-demo-inventory/main.py
KillMode=mixed
Restart=on-failure
RestartSec=1s
Expand Down
2 changes: 1 addition & 1 deletion inventory/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: |
vendor: Odigos
homepage: https://odigos.io
depends:
- python3.11
- python3
contents:
- src: distribution/systemd.service
dst: /lib/systemd/system/odigos-demo-inventory.service
Expand Down
2 changes: 1 addition & 1 deletion membership/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.4 as builder
FROM golang:1.21.4 AS builder
WORKDIR /go/src/app
COPY . .
RUN CGO_ENABLED=0 go build -o /go/bin/membership main.go
Expand Down
1 change: 1 addition & 0 deletions pricing/distribution/copy-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker cp tc:/app ./dist/app
2 changes: 1 addition & 1 deletion pricing/distribution/systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ After=network.target

[Service]
#ExecStart=/opt/odigos-demo-pricing/pricing
ExecStart=dotnet /opt/odigos-demo-pricing/app/pricing.dll
ExecStart=dotnet /opt/odigos-demo-pricing/pricing.dll
KillMode=mixed
Restart=on-failure
RestartSec=1s
Expand Down

0 comments on commit 13aeb95

Please sign in to comment.