Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 2b9da9a

Browse files
committed
Initial container implementation
1 parent 8ea862d commit 2b9da9a

File tree

6 files changed

+228
-0
lines changed

6 files changed

+228
-0
lines changed

.github/workflows/ci-image.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build Image CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- "*"
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v3
19+
-
20+
name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
-
23+
name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
-
27+
name: Login to GitHub Container Registry
28+
uses: docker/login-action@v2
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
-
34+
name: Build
35+
uses: docker/build-push-action@v3
36+
with:
37+
context: .
38+
platforms: linux/amd64
39+
push: false
40+
build-args: |
41+
VERSION=latest

.github/workflows/ghcr-image.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Image CI
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
concurrency:
9+
group: "docker-image"
10+
cancel-in-progress: true
11+
12+
env:
13+
DOCKER_BUILDKIT: "1"
14+
15+
jobs:
16+
docker:
17+
runs-on: ubuntu-latest
18+
steps:
19+
-
20+
name: Checkout
21+
uses: actions/checkout@v3
22+
-
23+
name: Set up QEMU
24+
uses: docker/setup-qemu-action@v2
25+
-
26+
name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
-
30+
name: Login to GitHub Container Registry
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
-
37+
name: Generate repository name
38+
run: |
39+
echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV}
40+
echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-7 )" >> ${GITHUB_ENV}
41+
-
42+
name: Build and Push
43+
uses: docker/build-push-action@v3
44+
with:
45+
context: .
46+
platforms: linux/amd64,linux/arm64
47+
push: true
48+
build-args: |
49+
VERSION=${{ github.ref_name }}
50+
tags: |
51+
ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }}
52+
ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }}
53+
ghcr.io/${{ env.REPOSITORY_PATH }}:latest
54+
-
55+
name: GitHub Release
56+
uses: actions/create-release@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
draft: false
61+
prerelease: false
62+
tag_name: ${{ github.ref_name }}
63+
release_name: v${{ github.ref_name }}
64+
body_path: CHANGELOG.md

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.0.0 (2023-11-08)
2+
3+
* initial rust container

Dockerfile

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
FROM debian:stable-slim as builder
2+
# defined from build kit
3+
# DOCKER_BUILDKIT=1 docker build . -t ...
4+
ARG TARGETARCH
5+
6+
RUN export DEBIAN_FRONTEND=noninteractive && \
7+
apt update && \
8+
apt install -y -q --no-install-recommends \
9+
git curl gnupg2 build-essential \
10+
linux-headers-${TARGETARCH} libc6-dev \
11+
openssl libssl-dev pkg-config \
12+
ca-certificates apt-transport-https \
13+
python3 && \
14+
apt clean && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
RUN useradd --create-home -s /bin/bash xmtp
18+
RUN usermod -a -G sudo xmtp
19+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
20+
21+
WORKDIR /rustup
22+
## Rust
23+
ADD https://sh.rustup.rs /rustup/rustup.sh
24+
RUN chmod 755 /rustup/rustup.sh
25+
26+
ENV USER=xmtp
27+
USER xmtp
28+
RUN /rustup/rustup.sh -y --default-toolchain stable --profile minimal
29+
30+
ENV PATH=$PATH:~xmtp/.cargo/bin
31+
32+
FROM debian:stable-slim
33+
ARG TARGETARCH
34+
35+
RUN export DEBIAN_FRONTEND=noninteractive && \
36+
apt update && \
37+
apt install -y -q --no-install-recommends \
38+
ca-certificates apt-transport-https \
39+
sudo ripgrep procps build-essential \
40+
python3 python3-pip python3-dev \
41+
git curl protobuf-compiler && \
42+
apt clean && \
43+
rm -rf /var/lib/apt/lists/*
44+
45+
RUN echo "building platform $(uname -m)"
46+
47+
RUN useradd --create-home -s /bin/bash xmtp
48+
RUN usermod -a -G sudo xmtp
49+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
50+
51+
## Node and NPM
52+
RUN mkdir -p /usr/local/nvm
53+
ENV NVM_DIR=/usr/local/nvm
54+
55+
ENV NODE_VERSION=v20.9.0
56+
57+
ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh
58+
RUN bash /usr/local/etc/nvm/install.sh && \
59+
bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default"
60+
61+
ENV NVM_NODE_PATH ${NVM_DIR}/versions/node/${NODE_VERSION}
62+
ENV NODE_PATH ${NVM_NODE_PATH}/lib/node_modules
63+
ENV PATH ${NVM_NODE_PATH}/bin:$PATH
64+
65+
RUN npm install npm -g
66+
RUN npm install yarn -g
67+
68+
69+
## Rust from builder
70+
COPY --chown=xmtp:xmtp --from=builder /home/xmtp/.cargo /home/xmtp/.cargo
71+
COPY --chown=xmtp:xmtp --from=builder /home/xmtp/.rustup /home/xmtp/.rustup
72+
73+
USER xmtp
74+
75+
LABEL org.label-schema.build-date=$BUILD_DATE \
76+
org.label-schema.name="rust" \
77+
org.label-schema.description="Rust Development Container" \
78+
org.label-schema.url="https://github.com/xmtp/rust" \
79+
org.label-schema.vcs-ref=$VCS_REF \
80+
org.label-schema.vcs-url="git@github.com:xmtp/rust.git" \
81+
org.label-schema.vendor="xmtp" \
82+
org.label-schema.version=$VERSION \
83+
org.label-schema.schema-version="1.0" \
84+
org.opencontainers.image.description="Rust Development Container"

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 XMTP
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# install a local version of this image - useful on arm64 where there are currently no public
4+
# distributions
5+
6+
VERSION=$(git rev-parse HEAD | cut -c 1-8)
7+
8+
PROJECT=xmtp/$(basename ${PWD})
9+
10+
# cross platform okay:
11+
# --platform=amd64 or arm64
12+
DOCKER_BUILDKIT=1 docker build --progress plain . -t ${PROJECT}:${VERSION} \
13+
--build-arg VERSION=${VERSION} --build-arg MAXIMUM_THREADS=2 && \
14+
docker tag ${PROJECT}:${VERSION} ${PROJECT}:latest && \
15+
docker tag ${PROJECT}:${VERSION} ghcr.io/${PROJECT}:latest

0 commit comments

Comments
 (0)