Skip to content

Commit 224ad59

Browse files
authored
Update Dockerfile to run tests locally (#742)
Add tester.sh to simplify running the tests in the docker container locally Change-Id: Dockerfile
1 parent 8d80230 commit 224ad59

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,21 @@ EOF
6060

6161
WORKDIR /usr/src/josh
6262
RUN rustup component add rustfmt
63-
RUN rustup target add wasm32-unknown-unknown
6463
RUN cargo install --version 0.1.35 cargo-chef
6564
RUN cargo install --version 0.2.1 hyper_cgi --features=test-server
6665
RUN cargo install --version 0.10.0 graphql_client_cli
6766

6867
FROM dev as dev-local
6968

69+
RUN mkdir -p /opt/cache && \
70+
chmod 777 /opt/cache
71+
72+
VOLUME /opt/cache
73+
74+
ENV CARGO_TARGET_DIR=/opt/cache/cargo-target
75+
ENV CARGO_HOME=/opt/cache/cargo-cache
76+
RUN npm config set cache /opt/cache/npm-cache --global
77+
7078
FROM dev as dev-ci
7179

7280
COPY --from=dev-planner /usr/src/josh/recipe.json .
@@ -96,11 +104,11 @@ apt-get install --yes --no-install-recommends \
96104
rm -rf /var/lib/apt/lists/*
97105
EOF
98106

99-
COPY --from=dev /opt/git-install /opt/git-install
107+
COPY --from=dev --link=false /opt/git-install /opt/git-install
100108
ENV PATH=${PATH}:/opt/git-install/bin
101109

102-
COPY --from=build /usr/src/josh/target/release/josh-proxy /usr/bin/
103-
COPY --from=build /usr/src/josh/run-josh.sh /usr/bin/
104-
COPY --from=build /usr/src/josh/static/ /josh/static/
110+
COPY --from=build --link=false /usr/src/josh/target/release/josh-proxy /usr/bin/
111+
COPY --from=build --link=false /usr/src/josh/run-josh.sh /usr/bin/
112+
COPY --from=build --link=false /usr/src/josh/static/ /josh/static/
105113

106114
CMD sh /usr/bin/run-josh.sh

tester.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# this script can be used to run tests in the container used for deployement.
4+
# usage:
5+
# Run all tests: ./tester.sh
6+
# Run specific test: ./tester.sh path/to/test.t
7+
8+
set -e
9+
shopt -s extglob
10+
shopt -s inherit_errexit
11+
12+
if (( $# == 0 )); then
13+
tests="tests/{filter{**/,},proxy}/*.t"
14+
else
15+
tests="$*"
16+
fi
17+
18+
echo "running: $tests"
19+
20+
docker buildx build --target=dev-local -t josh-dev-local .
21+
docker run -it --rm\
22+
--workdir "$(pwd)"\
23+
--volume "$(pwd)":"$(pwd)"\
24+
--volume cache:/opt/cache\
25+
--user "$(id -u)":"$(id -g)"\
26+
josh-dev-local\
27+
bash -c "cargo build --workspace --all && sh run-tests.sh $tests"
28+

0 commit comments

Comments
 (0)