-
-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use caching filesystem to improve webserving performance (#1277)
* Experimental use of bg-sync container for performance * Add bgsync status into ddev list and friends * For tests that need to wait for sync, wait for the sync * Make app.Logs() work with ddev-router * Improve getErrLogsFromApp() * Give the router just a little longer to come up in healthcheck * Only prompt for opt-in if they haven't opted in
- Loading branch information
Showing
32 changed files
with
121,147 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Temporary build-tools artifacts to be ignored | ||
.go/ | ||
/bin/ | ||
/.container* | ||
/.push* | ||
/linux | ||
/darwin | ||
/.dockerfile | ||
/VERSION.txt | ||
/.docker_image | ||
# These are not artifacts that should be ignored | ||
!files/usr/bin/ | ||
!files/usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM alpine:3.8 | ||
|
||
RUN apk add --no-cache bash sudo rsync file | ||
|
||
# Install Unison from source with inotify support + remove compilation tools | ||
ARG UNISON_VERSION=2.51.2 | ||
RUN apk add --no-cache --virtual .build-dependencies build-base curl && \ | ||
apk add --no-cache inotify-tools tzdata && \ | ||
apk add --no-cache --repository http://dl-4.alpinelinux.org/alpine/edge/testing/ ocaml && \ | ||
curl -Ll https://github.com/bcpierce00/unison/archive/v${UNISON_VERSION}.tar.gz | tar zxv -C /tmp && \ | ||
cd /tmp/unison-${UNISON_VERSION} && \ | ||
sed -i -e 's/GLIBC_SUPPORT_INOTIFY 0/GLIBC_SUPPORT_INOTIFY 1/' src/fsmonitor/linux/inotify_stubs.c && \ | ||
make UISTYLE=text NATIVE=true STATIC=true && \ | ||
cp src/unison src/unison-fsmonitor /usr/local/bin && \ | ||
apk del .build-dependencies ocaml && \ | ||
rm -rf /tmp/unison-${UNISON_VERSION} | ||
|
||
ENV HOME="/root" \ | ||
UNISONLOCALHOSTNAME="container" | ||
|
||
# If run as UNISON_USER other than root, it still uses /root as $HOME | ||
RUN mkdir -p $HOME/.unison && chmod ugo+rwx $HOME && chmod ugo+rwx $HOME/.unison | ||
|
||
ADD files / | ||
|
||
# Copy the bg-sync script into /usr/local/bin. | ||
COPY /files/sync.sh /usr/local/bin/bg-sync | ||
RUN chmod +x /usr/local/bin/bg-sync | ||
|
||
HEALTHCHECK --start-period=30s --interval=10s --retries=5 CMD ["/healthcheck.sh"] | ||
CMD ["bg-sync"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Makefile for a standard golang repo with associated container | ||
|
||
##### These variables need to be adjusted in most repositories ##### | ||
|
||
# Docker repo for a push | ||
DOCKER_REPO ?= drud/ddev-bgsync | ||
|
||
# Top-level directories to build | ||
#SRC_DIRS := filexs drudapi secrets utils | ||
|
||
# Optional to docker build | ||
# DOCKER_ARGS = | ||
|
||
# VERSION can be set by | ||
# Default: git tag | ||
# make command line: make VERSION=0.9.0 | ||
# It can also be explicitly set in the Makefile as commented out below. | ||
|
||
# This version-strategy uses git tags to set the version string | ||
# VERSION can be overridden on make commandline: make VERSION=0.9.1 push | ||
VERSION := $(shell git describe --tags --always --dirty) | ||
# | ||
# This version-strategy uses a manual value to set the version string | ||
#VERSION := 1.2.3 | ||
|
||
# Each section of the Makefile is included from standard components below. | ||
# If you need to override one, import its contents below and comment out the | ||
# include. That way the base components can easily be updated as our general needs | ||
# change. | ||
#include ../build-tools/makefile_components/base_build_go.mak | ||
#include ../../build-tools/makefile_components/base_build_python-docker.mak | ||
include ../../build-tools/makefile_components/base_container.mak | ||
include ../../build-tools/makefile_components/base_push.mak | ||
#include build-tools/makefile_components/base_test_go.mak | ||
#include build-tools/makefile_components/base_test_python.mak | ||
|
||
test: | ||
true >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# bg-sync | ||
|
||
Forked from https://github.com/cweagans/docker-bg-sync at | ||
https://github.com/cweagans/docker-bg-sync/commit/4e39642ab414f2ba0b55eb3933203115e6ed2c0b | ||
|
||
Thanks! | ||
|
||
==================== | ||
|
||
This container continuously syncs files between two directories. This is useful | ||
for avoiding the filesystem slowness on Docker for Mac, for instance. It's also | ||
generally useful for any other time where you have a slow filesystem as a source | ||
of files that need to be read inside of a container. | ||
|
||
|
||
## Environment variables | ||
|
||
This container uses values from a handful of environment variables. These are | ||
documented below. | ||
|
||
* **`SYNC_SOURCE`** (default: `/source`): The path inside the container which | ||
will be used as the source of the file sync. Most of the time, you probably | ||
shouldn't change the value of this variable. Instead, just bind-mount your | ||
files into the container at `/source` and call it a day. | ||
* **`SYNC_DESTINATION`** (default: `/destination`): When files are changed in | ||
`SYNC_SOURCE`, they will be copied over to the equivalent paths in `SYNC_DESTINATION`. | ||
If you are using bg-sync to avoid filesystem slowness, you should set this | ||
path to whatever path the volume is at in your application container. In the | ||
example above, for instance, this would be `/var/www/myapp`. | ||
* **`SYNC_PREFER`** (default: `/source`): Control the conflict strategy to apply | ||
when there are conflits. By default the contents from the source folder are | ||
left unchanged but there is also the "newer" option to pick up the most | ||
recent files. | ||
* **`SYNC_VERBOSE`** (default: "0"): Set this variable to "1" to get more log | ||
output from Unison. | ||
* **`SYNC_MAX_INOTIFY_WATCHES`** (default: ''): If set, the sync script will | ||
attempt to increase the value of `fs.inotify.max_user_watches`. **IMPORTANT**: | ||
This requires that you run this container as a priviliged container. Otherwise, | ||
the inotify limit increase *will not work*. As always, when running a third | ||
party container as a priviliged container, look through the source thoroughly | ||
first to make sure it won't do anything nefarious. `sync.sh` should be pretty | ||
understandable. Go on - read it. I'll wait. | ||
* **`SYNC_EXTRA_UNISON_PROFILE_OPTS`** (default: ''): The value of this variable | ||
will be appended to the end of the Unison profile that's automatically generated | ||
when this container is started. Ensure that the syntax is valid. If you have | ||
more than one option that you want to add, simply make this a multiline string. | ||
**IMPORTANT**: The *ability* to add extra lines to your Unison profile is | ||
supported by the bg-sync project. The *results* of what might happen because | ||
of this configuration is *not*. Use this option at your own risk. | ||
* **`SYNC_NODELETE_SOURCE`** (default: '1'): Set this variable to "0" to allow | ||
Unison to sync deletions to the source directory. This could cause unpredictable | ||
behaviour with your source files. | ||
|
||
|
||
|
Oops, something went wrong.