Skip to content

Commit

Permalink
publish in same manifest, two platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
felipefdl committed Nov 15, 2024
1 parent 1d0f258 commit 3df8776
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ on:
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64/v8

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

Expand All @@ -36,15 +34,13 @@ jobs:
echo "TAG=latest" >> $GITHUB_ENV
fi
- name: Build and Push Docker Image for ${{ matrix.platform }}
- name: Build and Push Docker Image to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: ${{ matrix.platform }}
platforms: linux/amd64,linux/arm64/v8
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}
${{ env.DOCKER_IMAGE }}:${{ env.TAG }}
build-args:
BUILD_PLATFORM=${{ matrix.platform }}
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
24 changes: 22 additions & 2 deletions just_bin.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
function generateFileName(version, platform) {
import * as os from "os";

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

if (platform === "linux") {
if (arch === "x64") {
return "linux/amd64";
} else if (arch === "arm64") {
return "linux/arm64/v8";
} else 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 +32,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 3df8776

Please sign in to comment.