Skip to content

Commit

Permalink
Merge pull request #497 from isucon/rust/init
Browse files Browse the repository at this point in the history
rust: Initial implementation
  • Loading branch information
sorah authored Sep 15, 2021
2 parents f7170c8 + 679e929 commit c0b2627
Show file tree
Hide file tree
Showing 12 changed files with 4,813 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI for Rust backend

on:
push:
branches: [main]
paths:
- benchmarker/**/*
- webapp/rust/**/*
- .github/workflows/rust.yaml
pull_request:
paths:
- benchmarker/**/*
- webapp/rust/**/*
- .github/workflows/rust.yaml

jobs:
lint:
name: Lint
runs-on: self-hosted
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path webapp/rust/Cargo.toml -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path webapp/rust/Cargo.toml

test:
name: Test
runs-on: self-hosted
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Setup environment
run: make -C dev up TARGET=rust
- uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run benchmarker with -no-load
run: |
make -C benchmarker
benchmarker/bin/benchmarker -no-load -exit-status
- name: Teardown environment
if: ${{ always() }}
run: make -C dev down TARGET=rust
49 changes: 49 additions & 0 deletions dev/docker-compose-rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3'

services:
frontend:
build:
context: ../webapp/frontend
dockerfile: ../../dev/frontend/Dockerfile
volumes:
- ./nginx:/etc/nginx/conf.d
ports:
- "8080:80"
depends_on:
- backend
backend:
build:
context: ../webapp/rust
dockerfile: ../../dev/rust/Dockerfile
restart: always
environment:
MYSQL_HOSTNAME: mysql
DEBUG: "true"
entrypoint: dockerize -timeout 60s -wait tcp://mysql:3306
command: /webapp/rust/target/debug/isucholar
ports:
- "7000:7000"
depends_on:
- mysql
volumes:
- ../webapp/data:/webapp/data:ro
- ../webapp/sql:/webapp/sql:ro
mysql:
image: mysql
restart: always
# setup.sqlの代替
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: isucon
MYSQL_PASSWORD: isucon
MYSQL_DATABASE: isucholar
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
expose:
- "3306"
ports:
- "3306:3306"
volumes:
- mysql:/var/lib/mysql

volumes:
mysql:
18 changes: 18 additions & 0 deletions dev/rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM rust:1.55.0-buster

WORKDIR /webapp/rust

RUN apt-get update && apt-get install -y zip

ARG DOCKERIZE_VERSION=v0.6.1
RUN curl -sSfLO https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

COPY Cargo.lock /Cargo.toml ./
RUN mkdir src && echo 'fn main() {}' > src/main.rs && cargo build --locked && rm src/main.rs target/debug/deps/isucholar-*

COPY . ./
RUN cargo build --locked --frozen

CMD ["/webapp/rust/target/debug/isucholar"]
1 change: 1 addition & 0 deletions webapp/rust/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
1 change: 1 addition & 0 deletions webapp/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit c0b2627

Please sign in to comment.