aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile30
-rw-r--r--docker-compose.yml61
2 files changed, 91 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d54d9fa
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,30 @@
+FROM gentoo/portage:latest as portage
+FROM gentoo/stage3-amd64
+
+# Need a portage tree to build, use last nights.
+COPY --from=portage /usr/portage /usr/portage
+# Sandbox doesn't work well in docker.
+
+ENV FEATURES="-userpriv -usersandbox -sandbox"
+ENV USE="-bindist"
+
+RUN emerge -C openssh
+RUN emerge net-libs/nodejs
+# Bundler is how we install the ruby stuff.
+RUN emerge dev-ruby/bundler
+
+# Needed for changelogs.
+RUN git clone https://anongit.gentoo.org/git/repo/gentoo.git /mnt/packages-tree/gentoo/
+
+# Copy code into place.
+COPY ./ /var/www/packages.gentoo.org/htdocs/
+WORKDIR /var/www/packages.gentoo.org/htdocs/
+RUN bundler install
+
+# Git clones here.
+RUN cp /var/www/packages.gentoo.org/htdocs/config/secrets.yml.dist /var/www/packages.gentoo.org/htdocs/config/secrets.yml
+RUN sed -i 's/set_me/ENV["SECRET_KEY_BASE"]/'g /var/www/packages.gentoo.org/htdocs/config/secrets.yml
+
+# Precompile our assets.
+RUN rake assets:precompile
+CMD ["bundler", "exec", "thin", "start"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..7c10720
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,61 @@
+
+version: '2'
+# p.g.o consists nominally of:
+# A service to sync the tree to $TREE_DIR && update the index.
+# The index updater simply submits work items into sidekiq.
+# ElasticSearch to managed updates and serve documents.
+# SideKiq requires redis.
+#
+# To this end we define 4 containers.
+# - HTTP Serving: Serves the site, and the /sidekiq endpoing.
+# - Elasticsearch: runs the elasticsearch service.
+# - Redis: Run Redis for Sidekiq.
+# - Refresher: Syncs the package tree and pushes updates into sidekiq.
+services:
+ http-serving:
+ # Build from Dockerfile in .
+ build: .
+ ports:
+ - 5000
+ environment:
+ # "Redis:port" and "elasticsearch:port" refer to sibling containers.
+ - REDIS_PROVIDER=REDIS_URL
+ - REDIS_URL=redis://redis:6379
+ - ELASTICSEARCH_URL=elasticsearch:9200
+ - RAILS_SERVE_STATIC_FILES=1
+ - RAILS_ENV=production
+ - MEMCACHE_URL="memcache:11211"
+ - SECRET_KEY_BASE=6c9710aeb74dd88ff1d1b8f4bd6d7d8e0f340905d0974400fffd7246714aa703cf7bf4a98c0bc90317a3b803b82c0f9371e18ada19fc4eed9d6118077a249f50
+ depends_on:
+ - redis
+ - elasticsearch
+ command: bundle exec thin start -p 5000
+ sidekiq:
+ build: .
+ environment:
+ - RAILS_ENV=production
+ - RAILS_SERVE_STATIC_FILES=1
+ - REDIS_URL=redis://redis:6379
+ - MEMCACHE_URL="memcache:11211"
+ - ELASTICSEARCH_URL=elasticsearch:9200
+ - SECRET_KEY_BASE=6c9710aeb74dd88ff1d1b8f4bd6d7d8e0f340905d0974400fffd7246714aa703cf7bf4a98c0bc90317a3b803b82c0f9371e18ada19fc4eed9d6118077a249f50
+ depends_on:
+ - redis
+ - elasticsearch
+ command: bundle exec sidekiq -c 5
+ memcache:
+ image: memcached:latest
+ ports:
+ - 11211
+ elasticsearch:
+ # TODO(antarus): We should build a docker image for this based on gentoo.
+ image: docker.elastic.co/elasticsearch/elasticsearch:6.0.1
+ # Run in single-node config.
+ environment:
+ - discovery.type=single-node
+ ports:
+ - 9200
+ redis:
+ image: redis:4.0.6
+ ports:
+ - 6379