aboutsummaryrefslogtreecommitdiff
path: root/devtools/docker
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-06-15 15:00:16 -0400
committerJulie Qiu <julie@golang.org>2021-06-15 21:56:15 +0000
commit8bfb713a352766997b0e9942bbd459894bfb261b (patch)
treefaef174a68c836e48e985c70770f79b5c48fe6e6 /devtools/docker
parent67220486af4102a6a34c3735485d01a8054f6be7 (diff)
downloadgo-x-pkgsite-8bfb713a352766997b0e9942bbd459894bfb261b.tar.xz
devtools: move e2e/docker/*
The e2e docker setup is moved to devtools, since it will also be useful for developing locally. Moved and changed references for: - e2e/docker/Dockerfile.frontend -> devtools/docker/Dockerfile.frontend - e2e/docker/docker-compose.yaml -> devtools/docker/docker-compose.yaml - e2e/docker/run.sh -> devtools/run_e2e.sh Change-Id: Ibfcb84e68d07058ad1cccd67891c939c4e75aae3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/328252 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'devtools/docker')
-rw-r--r--devtools/docker/Dockerfile.frontend37
-rw-r--r--devtools/docker/docker-compose.yaml75
2 files changed, 112 insertions, 0 deletions
diff --git a/devtools/docker/Dockerfile.frontend b/devtools/docker/Dockerfile.frontend
new file mode 100644
index 00000000..4b09d4cd
--- /dev/null
+++ b/devtools/docker/Dockerfile.frontend
@@ -0,0 +1,37 @@
+# Copyright 2021 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This Dockerfile expects the build context to be the public repo root.
+
+################################################################
+FROM golang:1.15.5 AS builder
+# If you change the Go version above, change the FROM line below as well.
+
+# Set the working directory outside $GOPATH to ensure module mode is enabled.
+WORKDIR /src
+
+# Copy go.mod and go.sum into the container.
+# If they don't change, which is the common case, then docker can
+# cache this COPY and the subsequent RUN.
+COPY go.mod go.sum all.bash /
+
+# Download the dependencies.
+RUN go mod download
+
+# Copy the pkgsite repo from local machine into Docker client’s current working
+# directory, so that we can use it to build the frontend.
+# See .dockerignore at the repo root for excluded files.
+COPY . /src
+
+# Build the frontend.
+RUN go build -mod=readonly ./cmd/frontend
+
+################################################################
+FROM golang:1.15.5
+
+WORKDIR app
+
+COPY --from=builder src/frontend frontend
+COPY static static
+COPY third_party third_party
diff --git a/devtools/docker/docker-compose.yaml b/devtools/docker/docker-compose.yaml
new file mode 100644
index 00000000..c4549704
--- /dev/null
+++ b/devtools/docker/docker-compose.yaml
@@ -0,0 +1,75 @@
+# Copyright 2021 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+version: '3'
+services:
+ e2e:
+ image: node:14.17.0
+ depends_on:
+ - chrome
+ - frontend
+ environment:
+ # For cleaner log output from jest and npm install
+ - CI=true
+ - GO_DISCOVERY_E2E_BASE_URL=http://frontend:8080
+ - GO_DISCOVERY_E2E_CHROME_URL=ws://chrome:3000
+ - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
+ - WAITFORIT_TIMEOUT=300
+ command: bash -c "./third_party/wait-for-it/wait-for-it.sh frontend:8080 -- npm install && npx jest e2e/basic.test.ts"
+ volumes:
+ - ../../:/pkgsite
+ working_dir: /pkgsite
+ chrome:
+ image: browserless/chrome:1.46-chrome-stable
+ ports:
+ - 3000:3000
+ environment:
+ - CONNECTION_TIMEOUT=120000
+ frontend:
+ image: golang:1.15.5
+ depends_on:
+ - migrate
+ command: [
+ "./third_party/wait-for-it/wait-for-it.sh",
+ "db:5432",
+ "--",
+ "go",
+ "run",
+ "./cmd/frontend",
+ "-host=0.0.0.0:8080",
+ ]
+ environment:
+ - GO_DISCOVERY_DATABASE_USER=postgres
+ - GO_DISCOVERY_DATABASE_PASSWORD=postgres
+ - GO_DISCOVERY_DATABASE_HOST=db
+ - GO_DISCOVERY_DATABASE_NAME=discovery_e2e_test
+ - WAITFORIT_TIMEOUT=300
+ - PORT=8080
+ ports:
+ - 8080:8080
+ volumes:
+ - ../../:/pkgsite
+ working_dir: /pkgsite
+ migrate:
+ depends_on:
+ - db
+ image: migrate/migrate:v4.14.1
+ # TODO: add wait-for-it command here also.
+ command: [
+ '-path',
+ '/pkgsite/migrations',
+ '-database',
+ 'postgres://postgres:postgres@db:5432/discovery_e2e_test?sslmode=disable',
+ 'up',
+ ]
+ volumes:
+ - ../../:/pkgsite
+ working_dir: /pkgsite
+ db:
+ image: postgres:11.12
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ - POSTGRES_USER=postgres
+ - POSTGRES_DB=discovery_e2e_test
+ ports:
+ - 5428:5432