Skip to content

Commit df0964c

Browse files
committed
initial commit
0 parents  commit df0964c

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build and Push Docker Container
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
IMAGE_VERSION: rust_1.80.1-node_18.19.1
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v1
21+
22+
- name: Login to GitHub Container Registry
23+
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
24+
25+
- name: Build and push multi-platform Docker image
26+
run: |
27+
# Build and tag the Docker image with the version
28+
docker buildx create --use
29+
docker buildx build --push \
30+
--tag ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ env.IMAGE_VERSION }} \
31+
--platform linux/amd64,linux/arm64 .
32+
33+
env:
34+
DOCKER_CLI_ACI_AS_TEXT: "true"

Dockerfile

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
FROM buildpack-deps:bookworm
2+
3+
# ----------------------
4+
# rust 1.80.1 via https://github.com/rust-lang/docker-rust/blob/3b6565cd3b0b7c9cb084f07461cb959f7cf77c16/1.80.1/bookworm/Dockerfile
5+
# ----------------------
6+
LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust
7+
8+
ENV RUSTUP_HOME=/usr/local/rustup \
9+
CARGO_HOME=/usr/local/cargo \
10+
PATH=/usr/local/cargo/bin:$PATH \
11+
RUST_VERSION=1.80.1
12+
13+
RUN set -eux; \
14+
dpkgArch="$(dpkg --print-architecture)"; \
15+
case "${dpkgArch##*-}" in \
16+
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41f920f56d' ;; \
17+
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='3c4114923305f1cd3b96ce3454e9e549ad4aa7c07c03aec73d1a785e98388bed' ;; \
18+
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='1cffbf51e63e634c746f741de50649bbbcbd9dbe1de363c9ecef64e278dba2b2' ;; \
19+
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='0a6bed6e9f21192a51f83977716466895706059afb880500ff1d0e751ada5237' ;; \
20+
ppc64el) rustArch='powerpc64le-unknown-linux-gnu'; rustupSha256='079430f58ad4da1d1f4f5f2f0bd321422373213246a93b3ddb53dad627f5aa38' ;; \
21+
s390x) rustArch='s390x-unknown-linux-gnu'; rustupSha256='e7f89da453c8ce5771c28279d1a01d5e83541d420695c74ec81a7ec5d287c51c' ;; \
22+
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
23+
esac; \
24+
url="https://static.rust-lang.org/rustup/archive/1.27.1/${rustArch}/rustup-init"; \
25+
wget "$url"; \
26+
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
27+
chmod +x rustup-init; \
28+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
29+
rm rustup-init; \
30+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
31+
rustup --version; \
32+
cargo --version; \
33+
rustc --version;
34+
35+
# ----------------------
36+
# cargo-chef via https://github.com/LukeMathWalker/cargo-chef/blob/main/docker/Dockerfile
37+
# using cargoc-chef version
38+
# ----------------------
39+
ENV CHEF_TAG=0.1.67
40+
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
41+
42+
# Install musl-dev on Alpine to avoid error "ld: cannot find crti.o: No such file or directory"
43+
RUN ((cat /etc/os-release | grep ID | grep alpine) && apk add --no-cache musl-dev || true) \
44+
&& cargo install cargo-chef --locked --version $CHEF_TAG \
45+
&& rm -rf $CARGO_HOME/registry/
46+
47+
# ----------------------
48+
# node 18.19.1 via https://github.com/nodejs/docker-node/blob/619b871fb3d89dc6d6333914b46bf526e781eec5/18/bookworm/Dockerfile
49+
# ----------------------
50+
RUN groupadd --gid 1000 node \
51+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
52+
53+
ENV NODE_VERSION 18.19.1
54+
55+
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
56+
&& case "${dpkgArch##*-}" in \
57+
amd64) ARCH='x64';; \
58+
ppc64el) ARCH='ppc64le';; \
59+
s390x) ARCH='s390x';; \
60+
arm64) ARCH='arm64';; \
61+
armhf) ARCH='armv7l';; \
62+
i386) ARCH='x86';; \
63+
*) echo "unsupported architecture"; exit 1 ;; \
64+
esac \
65+
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
66+
&& export GNUPGHOME="$(mktemp -d)" \
67+
# gpg keys listed at https://github.com/nodejs/node#release-keys
68+
&& set -ex \
69+
&& for key in \
70+
4ED778F539E3634C779C87C6D7062848A1AB005C \
71+
141F07595B7B3FFE74309A937405533BE57C7D57 \
72+
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
73+
DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \
74+
61FC681DFB92A079F1685E77973F295594EC4689 \
75+
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
76+
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
77+
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
78+
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
79+
108F52B48DB57BB0CC439B2997B01419BD92F80A \
80+
A363A499291CBBC940DD62E41F10027AF002F8B0 \
81+
CC68F5A3106FF448322E48ED27F5E38D5B0A215F \
82+
; do \
83+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
84+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
85+
done \
86+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
87+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
88+
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
89+
&& gpgconf --kill all \
90+
&& rm -rf "$GNUPGHOME" \
91+
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
92+
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
93+
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
94+
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
95+
# smoke tests
96+
&& node --version \
97+
&& npm --version
98+
99+
ENV YARN_VERSION 1.22.19
100+
101+
RUN set -ex \
102+
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
103+
&& export GNUPGHOME="$(mktemp -d)" \
104+
&& for key in \
105+
6A010C5166006599AA17F08146C2130DFD2497F5 \
106+
; do \
107+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
108+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
109+
done \
110+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
111+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
112+
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
113+
&& gpgconf --kill all \
114+
&& rm -rf "$GNUPGHOME" \
115+
&& mkdir -p /opt \
116+
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
117+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
118+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
119+
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
120+
# smoke test
121+
&& yarn --version \
122+
&& rm -rf /tmp/*

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# rust-node-container
2+
3+
This builds a Docker image that contains a combination of Rust (with chef-cargo) and Node.
4+
5+
The Dockerfile links to where each of the original Dockerfiles came from.

0 commit comments

Comments
 (0)