-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from isucon/rust/init
rust: Initial implementation
- Loading branch information
Showing
12 changed files
with
4,813 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Oops, something went wrong.