Skip to content

Commit 5eccf2f

Browse files
committed
feat: add ARM64 support with official Ruby + jemalloc
- Switch from fullstaq-ruby to official ruby:2.7.8-slim (fullstaq doesn't support ARM64) - Add libjemalloc2 with LD_PRELOAD for memory optimization - Implement multi-arch builds (linux/amd64 + linux/arm64) using QEMU + buildx - Automate ECR Public sync in GitHub Actions workflow - Translate all documentation and comments to English - Fix hadolint warnings and security issues
1 parent 5d24c14 commit 5eccf2f

File tree

3 files changed

+112
-36
lines changed

3 files changed

+112
-36
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build and Publish
33
on:
44
create:
55
tags:
6-
- '*'
6+
- '*'
77

88
jobs:
99
build-and-push-docker-image:
@@ -12,24 +12,61 @@ jobs:
1212

1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
1622

1723
- name: Docker meta
1824
id: meta
19-
uses: docker/metadata-action@v4
25+
uses: docker/metadata-action@v5
2026
with:
2127
images: polydice/base
2228
tags: type=ref,event=tag
2329

2430
- name: Login to DockerHub
25-
uses: docker/login-action@v2
31+
uses: docker/login-action@v3
2632
with:
2733
username: ${{ secrets.DOCKERHUB_USERNAME }}
2834
password: ${{ secrets.DOCKERHUB_TOKEN }}
2935

30-
- name: Build image and push to Docker Hub
31-
uses: docker/build-push-action@v3
36+
- name: Build and push
37+
uses: docker/build-push-action@v6
3238
with:
3339
push: true
3440
context: .
35-
tags: ${{ steps.meta.outputs.tags }}
41+
platforms: linux/amd64,linux/arm64
42+
tags: ${{ steps.meta.outputs.tags }}
43+
44+
sync-to-ecr:
45+
name: Sync to ECR Public
46+
needs: build-and-push-docker-image
47+
runs-on: ubuntu-latest
48+
if: success()
49+
50+
steps:
51+
- name: Configure AWS credentials
52+
uses: aws-actions/configure-aws-credentials@v4
53+
with:
54+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
55+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
56+
aws-region: us-east-1
57+
58+
- name: Login to Amazon ECR Public
59+
uses: aws-actions/amazon-ecr-login@v2
60+
with:
61+
registry-type: public
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Sync multi-arch image to ECR
67+
run: |
68+
set -e
69+
docker buildx imagetools create \
70+
--tag public.ecr.aws/z1n0q3w1/base:${{ github.ref_name }} \
71+
polydice/base:${{ github.ref_name }}
72+
echo "Successfully synced to ECR Public"

Dockerfile

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
ARG RUBY_VERSION=2.7.8
2-
ARG VARIANT=jemalloc-slim
3-
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base
2+
FROM ruby:${RUBY_VERSION}-slim
43

5-
ARG BUNDLER_VERSION=2.4.20
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
6+
# jemalloc for better memory management
7+
RUN apt-get update && apt-get install -y --no-install-recommends libjemalloc2 \
8+
&& JEMALLOC_PATH=$(find /usr/lib -name "libjemalloc.so.2" | head -1) \
9+
&& [ -n "$JEMALLOC_PATH" ] || (echo "libjemalloc.so.2 not found" && exit 1) \
10+
&& ln -sf "$JEMALLOC_PATH" /usr/lib/libjemalloc.so.2 \
11+
&& rm -rf /var/lib/apt/lists/*
12+
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
13+
14+
# Install build tools and native extension dependencies
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
build-essential \
17+
libpq-dev \
18+
libffi-dev \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
ARG BUNDLER_VERSION=2.4.22
622
RUN gem install -N bundler -v ${BUNDLER_VERSION}
723

824
ARG NODE_VERSION=18.18.0
925
ARG YARN_VERSION=1.22.22
1026
ARG PNPM_VERSION=9.9.0
11-
RUN curl https://get.volta.sh | bash
12-
ENV VOLTA_HOME /root/.volta
27+
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
28+
&& rm -rf /var/lib/apt/lists/* \
29+
&& curl -fsSL https://get.volta.sh | bash
30+
ENV VOLTA_HOME=/root/.volta
1331
ENV VOLTA_FEATURE_PNPM=1
14-
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH
32+
ENV PATH=$VOLTA_HOME/bin:/usr/local/bin:$PATH
1533
RUN volta install node@${NODE_VERSION} && volta install yarn@${YARN_VERSION} && volta install pnpm@${PNPM_VERSION}
1634

1735
RUN apt-get update \
@@ -23,28 +41,24 @@ RUN apt-get update \
2341
graphicsmagick \
2442
file \
2543
tar \
26-
curl \
27-
ca-certificates \
28-
libmcrypt4 \
2944
shared-mime-info \
45+
libmcrypt4 \
3046
&& rm -rf /var/lib/apt/lists/*
3147

48+
# Don't add g++/make to buildDeps, or purge will remove build-essential
49+
WORKDIR /tmp
3250
RUN set -ex \
33-
\
34-
&& buildDeps=' \
35-
g++ \
36-
make \
37-
cmake \
38-
python \
39-
' \
51+
&& buildDeps='cmake python3' \
4052
&& apt-get update \
4153
&& apt-get install -y --no-install-recommends $buildDeps \
4254
&& rm -rf /var/lib/apt/lists/* \
43-
\
44-
&& curl -L https://github.com/BYVoid/OpenCC/archive/refs/tags/ver.1.1.9.tar.gz | tar -xz \
45-
&& cd OpenCC-ver.1.1.9 \
46-
&& REL_BUILD_DOCUMENTATION=OFF make install \
47-
\
48-
&& apt-get purge -y --auto-remove $buildDeps \
49-
&& cd ../ \
55+
&& curl -L https://github.com/BYVoid/OpenCC/archive/refs/tags/ver.1.1.9.tar.gz | tar -xz
56+
57+
WORKDIR /tmp/OpenCC-ver.1.1.9
58+
RUN REL_BUILD_DOCUMENTATION=OFF make install
59+
60+
WORKDIR /tmp
61+
RUN apt-get purge -y --auto-remove cmake python3 \
5062
&& rm -rf OpenCC-ver.1.1.9
63+
64+
WORKDIR /app

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,36 @@ Polydice's base docker image for Rails applications.
77
- `x.y.z` - Standard image for running on production
88
- `x.y.z-testing` - Image for testing which includes additional packages.
99

10+
## Architectures
11+
12+
- `linux/amd64` (x86_64)
13+
- `linux/arm64` (Graviton, Apple Silicon)
14+
1015
## Versions
1116

12-
| Version | Ruby | Node.js | Yarn | Bundler | pnpm |
13-
|---------|-------|---------|---------|---------|-------|
14-
| 0.31.2 | 2.7.8 | 18.18.0 | 1.22.22 | 2.4.20 | 9.9.0 |
15-
| 0.31.1 | 2.7.8 | 18.18.0 | 1.22.19 | 2.4.20 | 8.8.0 |
16-
| 0.31.0 | 2.7.7 | 18.18.0 | 1.22.19 | 2.4.5 | 8.8.0 |
17-
| 0.30.3 | 2.7.7 | 14.21.2 | 1.22.19 | 2.4.5 | |
17+
| Version | Ruby | Node.js | Yarn | Bundler | pnpm | ARM64 |
18+
|---------|-------|---------|---------|---------|-------|-------|
19+
| 0.32.0 | 2.7.8 | 18.18.0 | 1.22.22 | 2.4.22 | 9.9.0 ||
20+
| 0.31.2 | 2.7.8 | 18.18.0 | 1.22.22 | 2.4.20 | 9.9.0 ||
21+
| 0.31.1 | 2.7.8 | 18.18.0 | 1.22.19 | 2.4.20 | 8.8.0 ||
22+
| 0.31.0 | 2.7.7 | 18.18.0 | 1.22.19 | 2.4.5 | 8.8.0 ||
23+
| 0.30.3 | 2.7.7 | 14.21.2 | 1.22.19 | 2.4.5 | ||
24+
25+
## Release
26+
27+
1. Update version in README.md
28+
2. Commit and push tag:
29+
```bash
30+
git tag <version>
31+
git push origin <version>
32+
```
33+
3. GitHub Actions will automatically:
34+
- Build multi-arch images (amd64 + arm64)
35+
- Push to DockerHub
36+
- Sync to ECR Public
37+
38+
## Changes in 0.32.0
39+
40+
- Switched from fullstaq-ruby to official Ruby image
41+
- Added jemalloc via `LD_PRELOAD`
42+
- Added ARM64 (linux/arm64) support

0 commit comments

Comments
 (0)