Skip to content

Commit 2f15949

Browse files
author
Paul WARD
committed
Initial Commit
0 parents  commit 2f15949

File tree

10 files changed

+350
-0
lines changed

10 files changed

+350
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OSX Specific files
2+
.DS_Store
3+
4+
# Logs
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# Dependency directories
10+
node_modules/
11+
12+
# Yarn Integrity file
13+
.yarn-integrity

Dockerfile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#
2+
# Notes:
3+
# Install Bazel, https://bazel.build/versions/master/docs/install.html#ubuntu
4+
#
5+
FROM openjdk:8
6+
7+
# Add an alias for 'll'
8+
RUN echo "alias ll='ls -al'" | tee -a ~/.bashrc
9+
10+
ENV DEBIAN_FRONTEND noninteractive
11+
RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
12+
&& curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
13+
14+
RUN apt-get update \
15+
&& apt-get install --no-install-recommends -y \
16+
g++ \
17+
build-essential \
18+
rsync \
19+
zip \
20+
unzip \
21+
less \
22+
nano \
23+
netcat \
24+
bazel \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Set up workspace
28+
RUN mkdir -p /src
29+
ENV WORKSPACE /src
30+
WORKDIR /src
31+
32+
####################################
33+
# Taken from official node image for 8.11.4 at:
34+
# https://github.com/nodejs/docker-node/blob/72dd945d29dee5afa73956ebc971bf3a472442f7/8/stretch/Dockerfile
35+
####################################
36+
37+
RUN groupadd --gid 1000 node \
38+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
39+
40+
# gpg keys listed at https://github.com/nodejs/node#release-team
41+
RUN set -ex \
42+
&& for key in \
43+
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
44+
FD3A5288F042B6850C66B31F09FE44734EB7990E \
45+
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
46+
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
47+
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
48+
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
49+
56730D5401028683275BD23C23EFEFE93C4CFFFE \
50+
77984A986EBC2AA786BC0F66B01FBB92821C587A \
51+
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
52+
; do \
53+
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
54+
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
55+
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
56+
done
57+
58+
ENV NODE_VERSION 8.11.4
59+
60+
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
61+
&& case "${dpkgArch##*-}" in \
62+
amd64) ARCH='x64';; \
63+
ppc64el) ARCH='ppc64le';; \
64+
s390x) ARCH='s390x';; \
65+
arm64) ARCH='arm64';; \
66+
armhf) ARCH='armv7l';; \
67+
i386) ARCH='x86';; \
68+
*) echo "unsupported architecture"; exit 1 ;; \
69+
esac \
70+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
71+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
72+
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
73+
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
74+
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
75+
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
76+
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
77+
78+
ENV YARN_VERSION 1.10.1
79+
80+
RUN set -ex \
81+
&& for key in \
82+
6A010C5166006599AA17F08146C2130DFD2497F5 \
83+
; do \
84+
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
85+
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
86+
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
87+
done \
88+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
89+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
90+
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
91+
&& mkdir -p /opt \
92+
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
93+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
94+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
95+
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz
96+
97+
RUN yarn global add @bazel/ibazel

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Bazel Toy
2+
3+
For now this only serves public files using ts_devserver.
4+
5+
The workspace config was taken mostly from [here](https://github.com/bazelbuild/rules_nodejs/pull/217)

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "2.1"
2+
3+
volumes:
4+
bazel_cache:
5+
bazel_repository_cache:
6+
yarn_cache:
7+
8+
services:
9+
devserver:
10+
build:
11+
context: .
12+
dockerfile: ./Dockerfile
13+
ports:
14+
- 3000:3000
15+
volumes:
16+
- ./packages:/src
17+
- bazel_cache:/root/.cache/bazel/
18+
- bazel_repository_cache:/root/.cache/bazel_repository_cache/
19+
- yarn_cache:/usr/local/share/.cache/yarn/
20+
working_dir: /src
21+
command: ["/usr/local/bin/ibazel", "run", "//devserver", "--", "--port=3000"]
22+
# command: ["/bin/bash", "-c", "echo \"sleeping indefinitely\"; while true; do sleep 100; done"]

packages/.bazelrc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
### Paul's notes
2+
### Most of this file was taken from
3+
### https://docs.bazel.build/versions/master/build-javascript.html
4+
###
5+
### Where this file should be placed:
6+
### ---------------------------------
7+
### As of 2018 1111, the link where this file came from incorrectly states that
8+
### this file should be placed into the %workspace%/tools/bazel.rc folder.
9+
### Instead the file should be placed in %workspace%/.bazel per issue #6319
10+
### https://github.com/bazelbuild/bazel/issues/6319 the file should be
11+
12+
###############################
13+
# Directory structure #
14+
###############################
15+
16+
# Globally cache downloaded artifacts.
17+
build --experimental_repository_cache=/root/.cache/bazel_repository_cache/
18+
test --experimental_repository_cache=/root/.cache/bazel_repository_cache/
19+
run --experimental_repository_cache=/root/.cache/bazel_repository_cache/
20+
21+
# Don't create bazel-* symlinks in the WORKSPACE directory. These
22+
# symlinks require .gitignore and may scare users. Instead, run
23+
# `bazel info bazel-bin` to find out where the outputs are stored.
24+
build --symlink_prefix=/
25+
26+
# Another good choice is to create a dist/ directory. Then you can
27+
# use build --symlink_prefix=dist/ to get folders like dist/bin.
28+
# Be aware that this setup will still create a bazel-out symlink in
29+
# your project directory, which you may need to exclude from the
30+
# editor's search path.
31+
32+
###############################
33+
# Output #
34+
###############################
35+
36+
# A more useful default output mode for bazel query, which
37+
# prints "ng_module rule //foo:bar" instead of just "//foo:bar".
38+
query --output=label_kind
39+
40+
# By default, failing tests don't print any output, it's logged to a
41+
# file instead.
42+
test --test_output=errors
43+
44+
# Show which actions are running under which workers and print all
45+
# the actions running in parallel. This shows that Bazel runs on all
46+
# cores of a CPU.
47+
build --experimental_ui
48+
test --experimental_ui
49+
50+
###############################
51+
# Typescript / Angular / Sass #
52+
###############################
53+
# Make TypeScript and Angular compilation fast, by keeping a few
54+
# copies of the compiler running as daemons, and cache SourceFile
55+
# ASTs to reduce parse time.
56+
#build --strategy=TypeScriptCompile=worker --strategy=AngularTemplateCompile=worker
57+
58+
# Enable debugging tests with --config=debug
59+
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results

packages/BUILD.bazel

Whitespace-only changes.

packages/WORKSPACE

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
workspace(name = "my_workspace")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
5+
6+
http_archive(
7+
name = "bazel_skylib",
8+
url = "https://github.com/bazelbuild/bazel-skylib/archive/0.3.1.zip",
9+
strip_prefix = "bazel-skylib-0.3.1",
10+
sha256 = "95518adafc9a2b656667bbf517a952e54ce7f350779d0dd95133db4eb5c27fb1",
11+
)
12+
13+
git_repository(
14+
name = "build_bazel_rules_nodejs",
15+
remote = "https://github.com/bazelbuild/rules_nodejs.git",
16+
tag = "0.15.1",
17+
)
18+
19+
http_archive(
20+
name = "io_bazel_rules_webtesting",
21+
url = "https://github.com/bazelbuild/rules_webtesting/archive/0.2.1.zip",
22+
strip_prefix = "rules_webtesting-0.2.1",
23+
sha256 = "7d490aadff9b5262e5251fa69427ab2ffd1548422467cb9f9e1d110e2c36f0fa",
24+
)
25+
26+
http_archive(
27+
name = "io_bazel_rules_go",
28+
url = "https://github.com/bazelbuild/rules_go/releases/download/0.14.0/rules_go-0.14.0.tar.gz",
29+
sha256 = "5756a4ad75b3703eb68249d50e23f5d64eaf1593e886b9aa931aa6e938c4e301",
30+
)
31+
32+
http_archive(
33+
name = "bazel_gazelle",
34+
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.14.0/bazel-gazelle-0.14.0.tar.gz"],
35+
sha256 = "c0a5739d12c6d05b6c1ad56f2200cb0b57c5a70e03ebd2f7b87ce88cabf09c7b",
36+
)
37+
38+
http_archive(
39+
name = "build_bazel_rules_typescript",
40+
url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.3.zip",
41+
strip_prefix = "rules_typescript-0.20.3",
42+
sha256 = "2a03b23c30c5109ab0863cfa60acce73ceb56337d41efc2dd67f8455a1c1d5f3",
43+
)
44+
45+
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
46+
node_repositories(
47+
node_version = "8.11.4",
48+
yarn_version = "1.10.1",
49+
node_repositories = {
50+
"8.11.4-darwin_amd64": ("node-v8.11.4-darwin-x64.tar.gz", "node-v8.11.4-darwin-x64", "aa1de83b388581d0d9ec3276f4526ee67e17e0f1bc0deb5133f960ce5dc9f1ef"),
51+
"8.11.4-linux_amd64": ("node-v8.11.4-linux-x64.tar.xz", "node-v8.11.4-linux-x64", "85ea7cbb5bf624e130585bfe3946e99c85ce5cb84c2aee474038bdbe912f908c"),
52+
"8.11.4-windows_amd64": ("node-v8.11.4-win-x64.zip", "node-v8.11.4-win-x64", "72a21e2fcd3703994f57cf707b92e7f939df99c3e0298102e7436849e4948536"),
53+
},
54+
yarn_repositories = {
55+
"1.10.1": ("yarn-v1.10.1.tar.gz", "yarn-v1.10.1", "97bf147cb28229e66e4e3c5733a93c851bbcb0f10fbc72696ed011774f4c6f1b"),
56+
},
57+
node_urls = ["https://nodejs.org/dist/v{version}/{filename}"],
58+
yarn_urls = ["https://github.com/yarnpkg/yarn/releases/download/v{version}/{filename}"],
59+
package_json = ["//:package.json"]
60+
)
61+
62+
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
63+
yarn_install(
64+
name = "npm",
65+
package_json = "//:package.json",
66+
yarn_lock = "//:yarn.lock",
67+
)
68+
69+
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
70+
go_rules_dependencies()
71+
go_register_toolchains()
72+
73+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
74+
gazelle_dependencies()
75+
76+
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", "web_test_repositories")
77+
web_test_repositories()
78+
browser_repositories(
79+
chromium = True,
80+
)
81+
82+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
83+
ts_setup_workspace()
84+
85+
# load("//:setup_workspace.bzl", "devserver_example_setup_workspace")
86+
# devserver_example_setup_workspace()

packages/devserver/BUILD.bazel

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package(default_visibility = ["//visibility:public"])
2+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
3+
4+
filegroup(
5+
name = "public_files",
6+
srcs = glob(
7+
include = ["public/**/*"],
8+
),
9+
)
10+
11+
ts_devserver(
12+
name = "devserver",
13+
14+
# serve these files rooted at /
15+
additional_root_paths = [
16+
"/my_workspace/devserver/public"
17+
# "npm/node_modules/zone.js/dist",
18+
],
19+
20+
# # Start from the development version of the main
21+
# entry_module = "angular_bazel_example/src/main.dev",
22+
# scripts = [
23+
# ":require.config.js",
24+
# ],
25+
# # This is the URL we'll point our <script> tag at
26+
# serving_path = "/bundle.min.js",
27+
# Serve these files in addition to the JavaScript bundle
28+
29+
static_files = [
30+
":public_files"
31+
# "@npm//node_modules/zone.js:dist/zone.min.js",
32+
],
33+
34+
# Tell Bazel to build the sources first
35+
# deps = ["//src"],
36+
)

packages/devserver/public/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE HTML>
2+
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<title>Bazel Toy</title>
7+
</head>
8+
<body>
9+
<section>
10+
<article>
11+
<header>
12+
<h2>Bazel Toy</h2>
13+
<p>Lets play with Bazel</p>
14+
</header>
15+
</article>
16+
</body>
17+
</html>

packages/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "packages",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "UNLICENSED",
11+
"devDependencies": {
12+
"@bazel/typescript": "0.20.3",
13+
"@bazel/karma": "0.20.3"
14+
}
15+
}

0 commit comments

Comments
 (0)