Skip to content

Commit

Permalink
Merge pull request #97 from isucon/feature/development-docker
Browse files Browse the repository at this point in the history
developmentディレクトリ以下に各言語実装に対応したMakefileなどを入れた
  • Loading branch information
mackee authored Jun 24, 2022
2 parents d3a9332 + 8ca2f0e commit 81832db
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
23 changes: 23 additions & 0 deletions development/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: install-initialdata init-mysql run-bench run-bench-noload

up/%:
docker compose -f docker-compose-$*.yml -f docker-compose-common.yml up -d

down/%:
docker compose -f docker-compose-$*.yml -f docker-compose-common.yml down -d

logs-webapp/%:
docker compose -f docker-compose-$*.yml -f docker-compose-common.yml logs -f webapp

install-initialdata:
docker compose -f docker-compose-common.yml cp ../initial_data/ bench:/home/isucon/

init-mysql:
docker compose -f docker-compose-common.yml exec --workdir /docker-entrypoint-initdb.d mysql \
bash -c 'cat 10_schema.sql 90_data.sql | mysql -uisucon -pisucon isuports'

run-bench:
docker compose -f docker-compose-common.yml exec bench ./run_local.sh

run-bench-noload:
docker compose -f docker-compose-common.yml exec bench ./run_local.sh -prepare-only
20 changes: 20 additions & 0 deletions development/backend-go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.18.3-bullseye

WORKDIR /tmp
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget gcc g++ make sqlite3 && \
wget -q https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb && \
apt-get -y install ./mysql-apt-config_*_all.deb && \
apt-get -y update && \
apt-get -y install mysql-client

RUN mkdir -p /home/isucon/webapp/go
WORKDIR /home/isucon/webapp/go

ENV GOPATH /home/isucon/go
ENV PATH /home/isucon/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN go install github.com/cespare/reflex@latest

CMD [ "reflex", "-r", "(\\.go$|go\\.mod)", "-s", "go", "run", "cmd/isuports/main.go" ]
67 changes: 67 additions & 0 deletions development/docker-compose-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3.0'

services:
nginx:
image: nginx:1.22
volumes:
- ../nginx/conf.d:/etc/nginx/conf.d
- ../nginx/tls:/etc/nginx/tls
#- ./public:/public
ports:
- "443:443"
network_mode: host
restart: always

mysql:
cpus: 1
mem_limit: 1g
image: mysql/mysql-server:8.0.29
environment:
- "MYSQL_ROOT_HOST=%"
- "MYSQL_ROOT_PASSWORD=root"
volumes:
- ../webapp/sql/admin/:/docker-entrypoint-initdb.d
- mysql:/var/lib/mysql
ports:
- 13306:3306
restart: always

blackauth:
build:
context: ../
dockerfile: ./development/backend-go/Dockerfile
ports:
- "3001:3001"
init: true
restart: always
volumes:
- ../:/home/isucon
working_dir: /home/isucon/blackauth
command:
- /usr/local/go/bin/go
- run
- main.go

bench:
build: ../webapp
stdin_open: true
tty: true
environment:
ISUCON_JWT_KEY_FILE: ./isuports.pem
volumes:
- ../:/home/isucon
- tenant_db:/home/isucon/webapp/tenant_db
- initial_data:/home/isucon/initial_data
- gopkg:/home/isucon/go/pkg
network_mode: host
working_dir: /home/isucon/bench
command:
- "bash"
- "-c"
- "sleep infinity"

volumes:
mysql:
gopkg:
tenant_db:
initial_data:
32 changes: 32 additions & 0 deletions development/docker-compose-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.0'

services:
webapp:
cpus: 1
mem_limit: 1g
build:
context: ../
dockerfile: ./development/backend-go/Dockerfile
environment:
ISUCON_DB_HOST: mysql
ISUCON_DB_PORT: 3306
ISUCON_DB_USER: isucon
ISUCON_DB_PASSWORD: isucon
ISUCON_DB_NAME: isuports
ISUCON_ADMIN_HOSTNAME: admin.t.isucon.dev
ports:
- "3000:3000"
links:
- mysql
volumes:
- ../webapp:/home/isucon/webapp
- tenant_db:/home/isucon/webapp/tenant_db
- initial_data:/home/isucon/initial_data
- gopkg:/home/isucon/go/pkg
init: true
restart: always

volumes:
gopkg:
tenant_db:
initial_data:

0 comments on commit 81832db

Please sign in to comment.