From 8ca2f0ecc6b139cf6cfb6632efd627101f03ae96 Mon Sep 17 00:00:00 2001 From: mackee Date: Fri, 24 Jun 2022 11:27:24 +0900 Subject: [PATCH] =?UTF-8?q?development=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=AA=E4=BB=A5=E4=B8=8B=E3=81=AB=E5=90=84=E8=A8=80?= =?UTF-8?q?=E8=AA=9E=E5=AE=9F=E8=A3=85=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=97?= =?UTF-8?q?=E3=81=9FMakefile=E3=81=AA=E3=81=A9=E3=82=92=E5=85=A5=E3=82=8C?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- development/Makefile | 23 +++++++++ development/backend-go/Dockerfile | 20 ++++++++ development/docker-compose-common.yml | 67 +++++++++++++++++++++++++++ development/docker-compose-go.yml | 32 +++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 development/Makefile create mode 100644 development/backend-go/Dockerfile create mode 100644 development/docker-compose-common.yml create mode 100644 development/docker-compose-go.yml diff --git a/development/Makefile b/development/Makefile new file mode 100644 index 00000000..aad5bb16 --- /dev/null +++ b/development/Makefile @@ -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 diff --git a/development/backend-go/Dockerfile b/development/backend-go/Dockerfile new file mode 100644 index 00000000..ae0366ae --- /dev/null +++ b/development/backend-go/Dockerfile @@ -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" ] diff --git a/development/docker-compose-common.yml b/development/docker-compose-common.yml new file mode 100644 index 00000000..78a2cdb5 --- /dev/null +++ b/development/docker-compose-common.yml @@ -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: diff --git a/development/docker-compose-go.yml b/development/docker-compose-go.yml new file mode 100644 index 00000000..2c222e05 --- /dev/null +++ b/development/docker-compose-go.yml @@ -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: