Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust, Docker dependencies, tooling #1340

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# syntax=docker/dockerfile:1.6-labs@sha256:bd24901c537a316a4802d920bf86605f4db8ef676ef7258a3b381e12d90c62c8
# syntax=docker/dockerfile:1.8@sha256:d6d396f3780b1dd56a3acbc975f57bd2fc501989b50164c41387c42d04e780d0

ARG ALPINE_VERSION=3.18
ARG ALPINE_VERSION=3.20
ARG ARCH=x86_64

FROM alpine:${ALPINE_VERSION} as rust-base
FROM alpine:${ALPINE_VERSION} AS rust-base

RUN apk add --no-cache ca-certificates gcc musl-dev

Expand All @@ -12,8 +12,12 @@ ENV CARGO_HOME=/usr/local/cargo
ENV PATH=/usr/local/cargo/bin:${PATH}

ARG ARCH
ARG RUSTUP_VERSION=1.26.0
ARG RUST_VERSION=1.74

# Update check: https://github.com/rust-lang/rustup/tags
ARG RUSTUP_VERSION=1.27.1

# Update check: https://github.com/rust-lang/rust/tags
ARG RUST_VERSION=1.79.0
ARG RUST_ARCH=${ARCH}-unknown-linux-musl

# https://github.com/sfackler/rust-openssl/issues/1462
Expand All @@ -27,17 +31,18 @@ RUN /tmp/rustup-init \
--default-toolchain ${RUST_VERSION} \
--default-host ${RUST_ARCH}

FROM rust-base as dev-planner
FROM rust-base AS dev-planner

RUN cargo install --version 0.1.62 cargo-chef
# Update check: https://github.com/LukeMathWalker/cargo-chef/releases
RUN cargo install --version 0.1.67 cargo-chef

WORKDIR /usr/src/josh
COPY . .

ENV CARGO_TARGET_DIR=/opt/cargo-target
RUN cargo chef prepare --recipe-path recipe.json

FROM rust-base as dev
FROM rust-base AS dev

RUN apk add --no-cache \
zlib-dev \
Expand All @@ -46,25 +51,28 @@ RUN apk add --no-cache \

WORKDIR /usr/src/josh
RUN rustup component add rustfmt
RUN cargo install --version 0.1.62 cargo-chef
RUN cargo install --version 0.1.67 cargo-chef
RUN cargo install --verbose --version 0.10.0 graphql_client_cli

RUN apk add --no-cache \
bash \
coreutils \
curl \
cmake \
make \
expat-dev \
gettext \
python3 \
python3-dev \
libffi-dev \
py3-pip \
tree \
autoconf \
libgit2-dev \
psmisc

ARG GIT_VERSION=2.38.1
# Update check: https://github.com/git/git/tags
ARG GIT_VERSION=2.45.2
WORKDIR /usr/src/git
RUN <<EOF
set -e
Expand All @@ -85,10 +93,12 @@ RUN mkdir /opt/git-install/etc
RUN git config -f /opt/git-install/etc/gitconfig --add safe.directory "*" && \
git config -f /opt/git-install/etc/gitconfig protocol.file.allow "always"

ARG CRAM_VERSION=d245cca
ARG PYGIT2_VERSION=1.11.1
RUN pip3 install \
git+https://github.com/brodie/cram.git@${CRAM_VERSION}
# Update check: https://github.com/prysk/prysk/releases
ARG PRYSK_VERSION=0.20.0

# This is a Docker image so --break-system-packages is okay
RUN pip3 install --break-system-packages \
git+https://github.com/prysk/prysk.git@${PRYSK_VERSION}

RUN apk add --no-cache go nodejs npm openssh-client patch

Expand All @@ -106,7 +116,7 @@ RUN cp bin/git-lfs /opt/git-lfs/bin

WORKDIR /usr/src/josh

FROM dev as dev-local
FROM dev AS dev-local

RUN mkdir -p /opt/cache && \
chmod 777 /opt/cache
Expand Down Expand Up @@ -140,12 +150,12 @@ RUN adduser \
-g '' \
dev

FROM dev as dev-cache
FROM dev AS dev-cache

COPY --from=dev-planner /usr/src/josh/recipe.json .
ENV CARGO_TARGET_DIR=/opt/cargo-target

FROM dev-cache as dev-ci
FROM dev-cache AS dev-ci

RUN mkdir -p /josh/static && \
chmod 777 /josh/static
Expand All @@ -156,7 +166,7 @@ RUN mkdir -p josh-ui
COPY josh-ui/package.json josh-ui/package-lock.json josh-ui/
RUN cd josh-ui && npm install

FROM dev-cache as build
FROM dev-cache AS build

RUN cargo chef cook --release --workspace --recipe-path recipe.json

Expand All @@ -167,7 +177,7 @@ RUN --mount=target=.git,from=git \
cargo build -p josh-proxy -p josh-ssh-shell --release

ARG ALPINE_VERSION
FROM alpine:${ALPINE_VERSION} as run
FROM alpine:${ALPINE_VERSION} AS run

RUN apk add --no-cache \
zlib \
Expand Down
26 changes: 20 additions & 6 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,36 @@ else
TARGET_DIR=${CARGO_TARGET_DIR}
fi

export PATH="${TARGET_DIR}/debug/:${PATH}"
export PATH="$(pwd)/scripts/:${PATH}"
OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
DATE_CMD="gdate"
else
DATE_CMD="date"
fi

PATH="${TARGET_DIR}/debug/:${PATH}"
PATH="$(pwd)/scripts/:${PATH}"
export PATH

export JOSH_COMMIT_TIME=0
export GIT_AUTHOR_NAME=Josh
export [email protected]
export GIT_AUTHOR_DATE="2005-04-07T22:13:13"

GIT_AUTHOR_DATE=$(${DATE_CMD} -R -d "2005-04-07T22:13:13Z")
export GIT_AUTHOR_DATE

export GIT_COMMITTER_NAME=Josh
export [email protected]
export GIT_COMMITTER_DATE="2005-04-07T22:13:13"
export EMPTY_TREE="4b825dc642cb6eb9a060e54bf8d69288fbee4904"

GIT_COMMITTER_DATE=$(${DATE_CMD} -R -d "2005-04-07T22:13:13Z")
export GIT_COMMITTER_DATE

export EMPTY_TREE="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
CONFIG_FILE=$(mktemp)
trap 'rm ${CONFIG_FILE}' EXIT

export GIT_CONFIG_GLOBAL=${CONFIG_FILE}
git config --global init.defaultBranch master

cargo fmt
python3 -m cram "$@"
python3 -m prysk "$@"
3 changes: 1 addition & 2 deletions tests/proxy/clone_absent_head.t
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
| | | `-- 2fc150c43f13cc56c0e9caeba01b58ec612022
| | |-- info
| | `-- pack
| |-- packed-refs
| `-- refs
| |-- heads
| |-- josh
Expand All @@ -127,6 +126,6 @@
|-- namespaces
`-- tags

27 directories, 16 files
27 directories, 15 files

$ cat ${TESTTMP}/josh-proxy.out
8 changes: 4 additions & 4 deletions tests/proxy/push_error.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
To http://localhost:8002/real_repo.git:prefix=pre.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://localhost:8002/real_repo.git:prefix=pre.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[1]

2 changes: 1 addition & 1 deletion tests/proxy/shell.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
$ sleep 1
$ kill -9 $!
$ grep "init mirror repo" proxy.out
* DEBUG josh_proxy: init mirror repo: "*/cramtests-*/shell.t/../../tmp/mirror" (glob)
* DEBUG josh_proxy: init mirror repo: "*/shell.t/../../tmp/mirror" (glob)
$ rm -Rf ../../tmp
Loading