Skip to content

Commit

Permalink
Fix Rust Sample Docker image (#2180)
Browse files Browse the repository at this point in the history
Looks like the Docker image and accompanying build scripts weren't
updated with the move to Tonic, so it all went 💥.

This fixes that, removing lots of dependencies we no long need (yay
Tonic), upgrading the Rust version, and making sure all the relevant
code (e.g. protos) are copies to the appropriate place when creating the
Docker build image.

Work on #2179
  • Loading branch information
markmandel authored Jul 13, 2021
1 parent efe0874 commit fb52741
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
29 changes: 2 additions & 27 deletions examples/rust-simple/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM rust:1.41.0 as builder
FROM rust:1.53.0 as builder
RUN useradd -m build

# Rust SDK depends on https://github.com/pingcap/grpc-rs and it requires CMake and Go

## Cmake
ENV CMAKE_MINOR_VERSION=v3.10 \
CMAKE_FULL_VERSION=3.10.3
RUN mkdir -p /usr/src/cmake \
&& curl -fSLO https://cmake.org/files/${CMAKE_MINOR_VERSION}/cmake-${CMAKE_FULL_VERSION}.tar.gz \
&& curl -fSLO https://cmake.org/files/${CMAKE_MINOR_VERSION}/cmake-${CMAKE_FULL_VERSION}-SHA-256.txt \
&& sha256sum -c cmake-${CMAKE_FULL_VERSION}-SHA-256.txt 2>&1 | grep OK \
&& tar xf cmake-${CMAKE_FULL_VERSION}.tar.gz -C /usr/src/cmake --strip-components=1 \
&& rm -f cmake-${CMAKE_FULL_VERSION}.* \
&& cd /usr/src/cmake \
&& ./configure && make -j$(nproc) && make install

## Go
ENV GO_VERSION=1.10.2 \
GO_CHECKSUM=4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff
RUN mkdir -p /usr/local/go \
&& curl -fSO https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz \
&& shasum -a 256 go${GO_VERSION}.linux-amd64.tar.gz | grep ${GO_CHECKSUM} \
&& tar xf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local/go --strip-components=1 \
&& rm -f go${GO_VERSION}.linux-amd64.tar.gz
ENV PATH $PATH:/usr/local/go/bin

# SDK
COPY sdk/src /home/builder/agones/sdks/rust/src
COPY sdk/Cargo.toml /home/builder/agones/sdks/rust/
COPY sdk /home/builder/agones/sdks/rust

# Example
COPY src /home/builder/agones/examples/rust-simple/src
Expand Down
5 changes: 2 additions & 3 deletions examples/rust-simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ build-server:
build-image:
# Docker does not allow to copy outside files
mkdir -p $(project_path)sdk
cp -rf $(project_path)../../sdks/rust/src $(project_path)sdk/src
cp -rf $(project_path)../../sdks/rust/Cargo.* $(project_path)sdk
cp -rf $(project_path)../../sdks/rust/* $(project_path)sdk
docker build $(project_path) --tag=$(server_tag)

# Run Rust Gameserver binary
Expand Down Expand Up @@ -80,4 +79,4 @@ gcr-check:

#output the tag for this image
echo-image-tag:
@echo $(server_tag)
@echo $(server_tag)
2 changes: 1 addition & 1 deletion examples/rust-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To learn how to deploy this example service to GKE, please see the tutorial [Bui

## Building

If you have a local rust developer environment installed locally, you can run `make build` to compile the code and
If you have a local rust developer environment installed locally, you can run `make build-server` to compile the code and
`make run` to execute the resulting binary.

If you want to build an updated container image or want to build the source code without installing the rust developer
Expand Down

0 comments on commit fb52741

Please sign in to comment.