-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
312: introduce remote container development environment
- devcontainer - tasks.json - github ci-image workflow - fmt and fix fmt errors - include Node 20.9.0 toolchain - review feedback, remove lint flow, README.md
- Loading branch information
1 parent
f33fd97
commit d903888
Showing
8 changed files
with
243 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile | ||
{ | ||
"name": "Existing Dockerfile", | ||
"build": { | ||
// Sets the run context to one level up instead of the .devcontainer folder. | ||
"context": "..", | ||
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. | ||
"dockerfile": "../Dockerfile" | ||
} | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
// "postCreateCommand": "cat /etc/os-release", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "devcontainer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Build Dev Image CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and Push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: false | ||
build-args: | | ||
VERSION=latest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"rust-lang.rust-analyzer" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "fmt", | ||
"type": "shell", | ||
"command": "cargo +nightly fmt --check", | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": "false" | ||
} | ||
}, | ||
{ | ||
"label": "build", | ||
"type": "shell", | ||
"command": "cargo build", | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": "false" | ||
} | ||
}, | ||
{ | ||
"label": "check", | ||
"type": "shell", | ||
"command": "cargo check", | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": "true" | ||
} | ||
}, | ||
{ | ||
"label": "test", | ||
"type": "shell", | ||
"command": "cargo test", | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"group": { | ||
"kind": "test", | ||
"isDefault": "true" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
FROM debian:stable-slim as go-builder | ||
# defined from build kit | ||
# DOCKER_BUILDKIT=1 docker build . -t ... | ||
ARG TARGETARCH | ||
|
||
FROM debian:stable-slim as builder | ||
# defined from build kit | ||
# DOCKER_BUILDKIT=1 docker build . -t ... | ||
ARG TARGETARCH | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt update && \ | ||
apt install -y -q --no-install-recommends \ | ||
git curl gnupg2 build-essential \ | ||
linux-headers-${TARGETARCH} libc6-dev \ | ||
openssl libssl-dev pkg-config \ | ||
ca-certificates apt-transport-https \ | ||
python3 && \ | ||
apt clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN useradd --create-home -s /bin/bash xmtp | ||
RUN usermod -a -G sudo xmtp | ||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
WORKDIR /rustup | ||
## Rust | ||
ADD https://sh.rustup.rs /rustup/rustup.sh | ||
RUN chmod 755 /rustup/rustup.sh | ||
|
||
ENV USER=xmtp | ||
USER xmtp | ||
RUN /rustup/rustup.sh -y --default-toolchain stable --profile minimal | ||
|
||
ENV PATH=$PATH:~xmtp/.cargo/bin | ||
|
||
FROM debian:stable-slim | ||
ARG TARGETARCH | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt update && \ | ||
apt install -y -q --no-install-recommends \ | ||
ca-certificates apt-transport-https \ | ||
sudo ripgrep procps build-essential \ | ||
python3 python3-pip python3-dev \ | ||
git curl && \ | ||
apt clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN echo "building platform $(uname -m)" | ||
|
||
RUN useradd --create-home -s /bin/bash xmtp | ||
RUN usermod -a -G sudo xmtp | ||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
## Node and NPM | ||
RUN mkdir -p /usr/local/nvm | ||
ENV NVM_DIR=/usr/local/nvm | ||
|
||
ENV NODE_VERSION=v20.9.0 | ||
|
||
ADD https://raw.githubusercontent.com/creationix/nvm/master/install.sh /usr/local/etc/nvm/install.sh | ||
RUN bash /usr/local/etc/nvm/install.sh && \ | ||
bash -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default" | ||
|
||
ENV NVM_NODE_PATH ${NVM_DIR}/versions/node/${NODE_VERSION} | ||
ENV NODE_PATH ${NVM_NODE_PATH}/lib/node_modules | ||
ENV PATH ${NVM_NODE_PATH}/bin:$PATH | ||
|
||
RUN npm install npm -g | ||
RUN npm install yarn -g | ||
|
||
|
||
## Rust from builder | ||
COPY --chown=xmtp:xmtp --from=builder /home/xmtp/.cargo /home/xmtp/.cargo | ||
COPY --chown=xmtp:xmtp --from=builder /home/xmtp/.rustup /home/xmtp/.rustup | ||
|
||
USER xmtp | ||
|
||
# fmt coming from nightly | ||
RUN ~xmtp/.cargo/bin/rustup toolchain install nightly | ||
RUN ~xmtp/.cargo/bin/rustup component add rustfmt --toolchain nightly | ||
RUN ~xmtp/.cargo/bin/rustup component add clippy | ||
|
||
WORKDIR /workspaces/libxmtp | ||
COPY --chown=xmtp:xmtp . . | ||
|
||
ENV PATH=~xmtp/.cargo/bin:$PATH | ||
ENV USER=xmtp | ||
|
||
RUN ~xmtp/.cargo/bin/cargo check | ||
RUN ~xmtp/.cargo/bin/cargo +nightly --version | ||
RUN ~xmtp/.cargo/bin/cargo +nightly fmt --check | ||
RUN ~xmtp/.cargo/bin/cargo clippy --all-features --no-deps | ||
RUN ~xmtp/.cargo/bin/cargo clippy --all-features --no-deps --manifest-path xmtp/Cargo.toml | ||
# some tests are setup as integration tests 👀 xmtp_mls | ||
RUN for crate in xmtp xmtp_api_grpc xmtp_api_grpc_gateway xmtp_cryptography xmtp_proto xmtp_v2; do cd ${crate}; ~xmtp/.cargo/bin/cargo test; done | ||
|
||
LABEL org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="rustdev" \ | ||
org.label-schema.description="Rust Development Container" \ | ||
org.label-schema.url="https://github.com/xmtp/libxmtp" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vcs-url="[email protected]:xmtp/libxmtp.git" \ | ||
org.label-schema.vendor="xmtp" \ | ||
org.label-schema.version=$VERSION \ | ||
org.label-schema.schema-version="1.0" \ | ||
org.opencontainers.image.description="Rust Development Container" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters