Skip to content

Commit a7aecd3

Browse files
committed
build: test iteration
1 parent acbf28a commit a7aecd3

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

.github/workflows/build_async.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- name: Checkout
4242
uses: actions/checkout@v3
4343

44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
4447
- name: Build amd64
4548
run: |
4649
echo "AMD64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}"
@@ -81,3 +84,10 @@ jobs:
8184
tags: |
8285
${{ needs.compute_tags.outputs.tag_latest }}
8386
${{ needs.compute_tags.outputs.tag_version }}
87+
88+
merge_amd64_and-amr64:
89+
runs-on: ubuntu-latest
90+
needs: [build_amd64, build_arm64]
91+
run: |
92+
echo "so two previous build should push to :arm & :amd tag, then now we are going to merge them to one"
93+
echo "docker manifest create yourdockerhubusername/yourimage:latest \nyourdockerhubusername/yourimage:amd \nyourdockerhubusername/yourimage:arm \n docker manifest push yourdockerhubusername/yourimage:latest"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build ASYNC NATIVE
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
env:
10+
DOCKER_HUB_IMAGE_NAME: "amd64-arm64"
11+
12+
jobs:
13+
compute_tags:
14+
runs-on: ubuntu-latest
15+
#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs
16+
outputs:
17+
tag_latest: ${{ steps.compute-tags.outputs.tag_latest }}
18+
tag_version: ${{ steps.compute-tags.outputs.tag_version }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Compute tags
24+
id: compute-tags
25+
run: |
26+
PACKAGE_VERSION=$(cat package.json | jq -r '.version')
27+
DOCKER_HUB_TAG_BASE=async/${DOCKER_HUB_IMAGE_NAME}:${{github.ref_name}}
28+
DOCKER_HUB_TAG_LATEST=${DOCKER_HUB_TAG_BASE}-latest
29+
if [ "${{github.ref_name}}" = "prod" ]; then
30+
DOCKER_HUB_TAG_VERSION=${DOCKER_HUB_TAG_BASE}-${PACKAGE_VERSION}
31+
else
32+
DOCKER_HUB_TAG_VERSION=""
33+
fi
34+
echo "tag_latest=${DOCKER_HUB_TAG_LATEST}" >> $GITHUB_OUTPUT
35+
echo "tag_version=${DOCKER_HUB_TAG_VERSION}" >> $GITHUB_OUTPUT
36+
37+
build_amd64:
38+
runs-on: ubuntu-latest
39+
needs: [compute_tags]
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Build amd64
48+
run: |
49+
echo "AMD64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}"
50+
echo "AMD64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}"
51+
52+
- name: Build image amd64
53+
uses: docker/build-push-action@v5
54+
with:
55+
context: .
56+
platforms: linux/amd64
57+
push: false
58+
tags: |
59+
${{ needs.compute_tags.outputs.tag_latest }}
60+
${{ needs.compute_tags.outputs.tag_version }}
61+
62+
build_arm64:
63+
runs-on: ubuntu-latest
64+
needs: [compute_tags]
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v3
68+
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
- name: Build arm64
73+
run: |
74+
echo "ARM64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}"
75+
echo "ARM64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}"
76+
77+
#Build and push docker image
78+
- name: Build and push image arm64
79+
uses: docker/build-push-action@v5
80+
with:
81+
context: ./Dockerfile.arm
82+
platforms: linux/arm64
83+
push: false
84+
tags: |
85+
${{ needs.compute_tags.outputs.tag_latest }}
86+
${{ needs.compute_tags.outputs.tag_version }}
87+
88+
merge_amd64_and-amr64:
89+
runs-on: ubuntu-latest
90+
needs: [build_amd64, build_arm64]
91+
run: |
92+
echo "so two previous build should push to :arm & :amd tag, then now we are going to merge them to one"
93+
echo "docker manifest create yourdockerhubusername/yourimage:latest \nyourdockerhubusername/yourimage:amd \nyourdockerhubusername/yourimage:arm \n docker manifest push yourdockerhubusername/yourimage:latest"

Dockerfile.arm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM --platform=arm64 node:22.16-alpine AS build-stage
2+
RUN apk update --no-cache && apk add --no-cache jq
3+
WORKDIR /opt/app
4+
COPY . ./
5+
RUN npm ci --include=dev \
6+
&& npm run build
7+
8+
# Create the final released image
9+
FROM --platform=arm64 node:22.16-alpine AS prod-stage
10+
RUN apk update --no-cache && apk add --no-cache curl
11+
WORKDIR /opt/app
12+
COPY --from=build-stage /opt/app/.output/ /opt/app/
13+
EXPOSE 3000
14+
CMD [ "node", "/opt/app/server/index.mjs" ]

0 commit comments

Comments
 (0)