Skip to content

Commit

Permalink
Merge branch 'main' into TCORE-226-Export_Device_Data
Browse files Browse the repository at this point in the history
  • Loading branch information
bgelatti authored Nov 18, 2024
2 parents 6c27c91 + 15a8ff3 commit eb4662a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 15 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/arm64/v8]
include:
- platform: linux/amd64
- platform: linux/arm64/v8
# - platform: linux/arm/v7
# - platform: linux/ppc64le
# - platform: linux/s390x
platform:
- linux/amd64
- linux/arm64/v8

steps:
- name: Check out the code
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish Docker image

on:
release:
types: [created]

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write

steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Tags
id: tags
run: |
echo "DOCKER_IMAGE=tagoio/tagocore" >> $GITHUB_ENV
echo "GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/tagocore" >> $GITHUB_ENV
if [[ ${{ github.ref_name }} == *"-beta"* ]]; then
echo "TAG=beta" >> $GITHUB_ENV
else
echo "TAG=latest" >> $GITHUB_ENV
fi
- name: Build and Push Docker Image to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}
${{ env.DOCKER_IMAGE }}:${{ env.TAG }}
${{ env.GHCR_IMAGE }}:${{ github.ref_name }}
${{ env.GHCR_IMAGE }}:${{ env.TAG }}
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM node:22-bookworm-slim

# Def
ARG BUILD_PLATFORM="linux/arm64/v8"
ENV BUILD_PLATFORM=$BUILD_PLATFORM

# Set the working directory
WORKDIR /tagocore

Expand All @@ -13,13 +9,13 @@ COPY . .
# Set environment variables
ENV JUST_VERSION=1.36.0

# RUN node just_bin.mjs ${JUST_VERSION} ${BUILD_PLATFORM} && exit 1
# RUN node just_bin.mjs ${JUST_VERSION} ${BUILD_PLATFORM} && exit 1;

# Install distro libs, download and install 'just', and clean up in a single RUN statement
RUN apt update && \
apt install -y curl netcat-openbsd && \
rm -rf /var/lib/apt/lists/* && \
export JUST_FILENAME=$(node just_bin.mjs ${JUST_VERSION} ${BUILD_PLATFORM}) && \
export JUST_FILENAME=$(node just_bin.mjs ${JUST_VERSION}) && \
curl -L -o just.tar.gz https://github.com/casey/just/releases/download/${JUST_VERSION}/$JUST_FILENAME && \
tar -xzf just.tar.gz && \
mv just /usr/local/bin/just && \
Expand Down
26 changes: 24 additions & 2 deletions just_bin.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
function generateFileName(version, platform) {
import * as os from "node:os";

function getPlatform() {
const arch = os.arch();
const platform = os.platform();

if (platform === "linux") {
if (arch === "x64") {
return "linux/amd64";
}
if (arch === "arm64") {
return "linux/arm64/v8";
}
if (arch === "arm") {
return "linux/arm/v7";
}
}

throw new Error(`Unsupported platform: ${platform} ${arch}`);
}

function generateFileName(version) {
const platform = getPlatform();
let arch = "";

if (platform === "linux/amd64") {
Expand All @@ -12,4 +34,4 @@ function generateFileName(version, platform) {
return `just-${version}-${arch}.tar.gz`;
}

console.log(generateFileName(process.argv[2], process.argv[3]));
console.log(generateFileName(process.argv[2]));

0 comments on commit eb4662a

Please sign in to comment.