Skip to content

Commit

Permalink
321: clean up +nightly in one more spot (#322)
Browse files Browse the repository at this point in the history
- use xmtp/rust container as prebuild
  • Loading branch information
jac18281828 authored Nov 9, 2023
1 parent 6706885 commit c7b6cb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 80 deletions.
20 changes: 18 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "fmt",
"type": "shell",
"command": "cargo +nightly fmt --check",
"command": "cargo fmt --check",
"options": {
"cwd": "${workspaceFolder}"
},
Expand All @@ -15,13 +15,27 @@
"isDefault": "false"
}
},
{
"label": "lint",
"type": "shell",
"command": "cargo clippy --all-features --no-deps",
"options": {
"cwd": "${workspaceFolder}"
},
"dependsOn": "fmt",
"group": {
"kind": "build",
"isDefault": "false"
}
},
{
"label": "build",
"type": "shell",
"command": "cargo build",
"options": {
"cwd": "${workspaceFolder}"
},
"dependsOn": "lint",
"group": {
"kind": "build",
"isDefault": "false"
Expand All @@ -34,6 +48,7 @@
"options": {
"cwd": "${workspaceFolder}"
},
"dependsOn": "lint",
"group": {
"kind": "build",
"isDefault": "true"
Expand All @@ -46,10 +61,11 @@
"options": {
"cwd": "${workspaceFolder}"
},
"dependsOn": "lint",
"group": {
"kind": "test",
"isDefault": "true"
}
}
]
}
}
79 changes: 1 addition & 78 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,80 +1,4 @@
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

FROM ghcr.io/xmtp/rust:latest
USER xmtp

RUN ~xmtp/.cargo/bin/rustup toolchain install stable
Expand All @@ -88,7 +12,6 @@ ENV PATH=~xmtp/.cargo/bin:$PATH
ENV USER=xmtp

RUN ~xmtp/.cargo/bin/cargo check
RUN ~xmtp/.cargo/bin/cargo --version
RUN ~xmtp/.cargo/bin/cargo 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
Expand Down

0 comments on commit c7b6cb2

Please sign in to comment.