├── debian └── buster │ ├── docker-compose.yml │ └── Dockerfile ├── README.md └── alpine ├── 3.4 └── Dockerfile ├── 3.8 └── Dockerfile └── 3.9 └── Dockerfile /debian/buster/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | 3 | services: 4 | runtime: 5 | image: icalialabs/watchman:buster-runtime 6 | build: &build_config 7 | context: . 8 | target: runtime 9 | builder: 10 | image: icalialabs/watchman:buster-builder 11 | build: 12 | <<: *build_config 13 | target: builder 14 | release: 15 | image: icalialabs/watchman:buster 16 | build: 17 | <<: *build_config 18 | target: release 19 | volumes: 20 | - ../..:/usr/src # Mount the whole project to do some tests... 21 | working_dir: /usr/src 22 | stdin_open: true 23 | tty: true 24 | command: watchman --foreground --log-level 2 watch /usr/src/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Facebook's Watchman for Docker Containers 2 | 3 | [Watchman](https://facebook.github.io/watchman/) is a file watching service 4 | developed by Facebook, and it's used by many projects (like Ember CLI) to watch 5 | files for changes, triggering project rebuilds whenever a change is detected. 6 | 7 | Instead of figuring out how to build watchman from source - or waiting for long 8 | compilation times when building your Dockerfiles - you can use the "Multi-stage 9 | Dockerfile" feature to copy the watchman executable directly from our image! 10 | 11 | ## Supported tags and respective Dockerfile links 12 | - [4.9.0-alpine3.8, 4.9.0-alpine, 4.9-alpine3.8, 4.9-alpine, 4-alpine, 4, latest](https://github.com/IcaliaLabs/docker-watchman/blob/master/alpine/3.8/Dockerfile) 13 | - [4.9.0-alpine3.4, 4.9-alpine3.4, 4-alpine3.4](https://github.com/IcaliaLabs/docker-watchman/blob/master/alpine/3.4/Dockerfile) 14 | - [debian, buster](https://github.com/IcaliaLabs/docker-watchman/blob/master/debian/buster/Dockerfile) 15 | 16 | ## Recommended usage on Alpine-based images: 17 | 18 | ``` 19 | # Start from whatever image you are using - this is a node app example: 20 | FROM node:8-alpine 21 | 22 | # Install the packages required for watchman to work properly: 23 | RUN apk add --no-cache libcrypto1.0 libgcc libstdc++ 24 | 25 | # Copy the watchman executable binary directly from our image: 26 | COPY --from=icalialabs/watchman:4-alpine3.4 /usr/local/bin/watchman* /usr/local/bin/ 27 | 28 | # Create the watchman STATEDIR directory: 29 | RUN mkdir -p /usr/local/var/run/watchman \ 30 | && touch /usr/local/var/run/watchman/.not-empty 31 | 32 | # (Optional) Copy the compiled watchman documentation: 33 | COPY --from=icalialabs/watchman:4-alpine3.4 /usr/local/share/doc/watchman* /usr/local/share/doc/ 34 | 35 | # Continue with the rest of your Dockerfile... 36 | ``` 37 | 38 | ## References 39 | 40 | ### Similar projects: 41 | - https://github.com/icalialabs/docker-wkhtmltopdf 42 | -------------------------------------------------------------------------------- /alpine/3.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage I: Runtime ============================================================= 2 | 3 | # Step 1: Begin with Alpine 3.4: 4 | FROM alpine:3.4 AS runtime 5 | 6 | # Step 2: Install watchman runtime dependencies: 7 | RUN apk add --no-cache libcrypto1.0 libgcc libstdc++ 8 | 9 | # Stage II: Builder ============================================================ 10 | 11 | # Step 3: Begin from runtime stage image: 12 | FROM runtime AS builder 13 | 14 | # Step 4: Install the watchman build dependencies' dependencies :) 15 | RUN apk add --no-cache --update ca-certificates openssl 16 | 17 | # Step 5: Install the watchman build dependencies: 18 | RUN apk add --no-cache \ 19 | automake \ 20 | autoconf \ 21 | bash \ 22 | build-base \ 23 | libtool \ 24 | linux-headers \ 25 | openssl-dev \ 26 | python-dev 27 | 28 | # Step 6: Set environment variables: 29 | ENV WATCHMAN_VERSION=4.9.0 \ 30 | WATCHMAN_SHA256=1f6402dc70b1d056fffc3748f2fdcecff730d8843bb6936de395b3443ce05322 31 | 32 | # Step 7: Download watchman source code: 33 | RUN cd /tmp \ 34 | && wget -O watchman.tar.gz "https://github.com/facebook/watchman/archive/v${WATCHMAN_VERSION}.tar.gz" \ 35 | && echo "$WATCHMAN_SHA256 *watchman.tar.gz" | sha256sum -c - \ 36 | && tar -xz -f watchman.tar.gz -C /tmp/ \ 37 | && rm -rf watchman.tar.gz 38 | 39 | # Step 8: Build watchman from source: 40 | RUN cd /tmp/watchman-${WATCHMAN_VERSION} \ 41 | && ./autogen.sh \ 42 | && ./configure \ 43 | && make \ 44 | && make install \ 45 | && cd $HOME \ 46 | && rm -rf /tmp/* 47 | 48 | # Stage III: Release =========================================================== 49 | 50 | # Step 9: Begin with the runtime stage image: 51 | FROM runtime AS release 52 | 53 | # Step 10: Copy the compiled executable: 54 | COPY --from=builder /usr/local/bin/watchman* /usr/local/bin/ 55 | 56 | # Step 11: Copy the documentation: 57 | COPY --from=builder /usr/local/share/doc/watchman-4.9.0 /usr/local/share/doc/watchman-4.9.0 58 | 59 | # Step 12: Copy the runtime directories: 60 | COPY --from=builder /usr/local/var/run/watchman /usr/local/var/run/watchman 61 | -------------------------------------------------------------------------------- /alpine/3.8/Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage I: Runtime ============================================================= 2 | 3 | # Step 1: Begin with Alpine 3.8: 4 | FROM alpine:3.8 AS runtime 5 | 6 | # Step 2: Install watchman runtime dependencies: 7 | RUN apk add --no-cache libcrypto1.0 libgcc libstdc++ 8 | 9 | # Stage II: Builder ============================================================ 10 | 11 | # Step 3: Begin from runtime stage image: 12 | FROM runtime AS builder 13 | 14 | # Step 4: Install the watchman build dependencies' dependencies :) 15 | RUN apk add --no-cache --update ca-certificates openssl 16 | 17 | # Step 5: Install the watchman build dependencies: 18 | RUN apk add --no-cache \ 19 | automake \ 20 | autoconf \ 21 | bash \ 22 | build-base \ 23 | libtool \ 24 | linux-headers \ 25 | openssl-dev \ 26 | python-dev 27 | 28 | # Step 6: Set environment variables: 29 | ENV WATCHMAN_VERSION=4.9.0 \ 30 | WATCHMAN_SHA256=1f6402dc70b1d056fffc3748f2fdcecff730d8843bb6936de395b3443ce05322 31 | 32 | # Step 7: Download watchman source code: 33 | RUN cd /tmp \ 34 | && wget -O watchman.tar.gz "https://github.com/facebook/watchman/archive/v${WATCHMAN_VERSION}.tar.gz" \ 35 | && echo "$WATCHMAN_SHA256 *watchman.tar.gz" | sha256sum -c - \ 36 | && tar -xz -f watchman.tar.gz -C /tmp/ \ 37 | && rm -rf watchman.tar.gz 38 | 39 | # Step 8: Build watchman from source: 40 | RUN cd /tmp/watchman-${WATCHMAN_VERSION} \ 41 | && ./autogen.sh \ 42 | && ./configure \ 43 | && make \ 44 | && make install \ 45 | && cd $HOME \ 46 | && rm -rf /tmp/* 47 | 48 | # Stage III: Release =========================================================== 49 | 50 | # Step 9: Begin with the runtime stage image: 51 | FROM runtime AS release 52 | 53 | # Step 10: Copy the compiled executable: 54 | COPY --from=builder /usr/local/bin/watchman* /usr/local/bin/ 55 | 56 | # Step 11: Copy the documentation: 57 | COPY --from=builder /usr/local/share/doc/watchman-4.9.0 /usr/local/share/doc/watchman-4.9.0 58 | 59 | # Step 12: Copy the runtime directories: 60 | COPY --from=builder /usr/local/var/run/watchman /usr/local/var/run/watchman 61 | -------------------------------------------------------------------------------- /alpine/3.9/Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage I: Runtime ============================================================= 2 | 3 | # Step 1: Begin with Alpine 3.9: 4 | FROM alpine:3.9 AS runtime 5 | 6 | # Step 2: Install watchman runtime dependencies: 7 | RUN apk add --no-cache libcrypto1.1 libgcc libstdc++ 8 | 9 | # Stage II: Builder ============================================================ 10 | 11 | # Step 3: Begin from runtime stage image: 12 | FROM runtime AS builder 13 | 14 | # Step 4: Install the watchman build dependencies' dependencies :) 15 | RUN apk add --no-cache --update ca-certificates openssl 16 | 17 | # Step 5: Install the watchman build dependencies: 18 | RUN apk add --no-cache \ 19 | automake \ 20 | autoconf \ 21 | bash \ 22 | build-base \ 23 | libtool \ 24 | linux-headers \ 25 | openssl-dev \ 26 | python-dev 27 | 28 | # Step 6: Set environment variables: 29 | ENV WATCHMAN_VERSION=4.9.0 \ 30 | WATCHMAN_SHA256=1f6402dc70b1d056fffc3748f2fdcecff730d8843bb6936de395b3443ce05322 31 | 32 | # Step 7: Download watchman source code: 33 | RUN cd /tmp \ 34 | && wget -O watchman.tar.gz "https://github.com/facebook/watchman/archive/v${WATCHMAN_VERSION}.tar.gz" \ 35 | && echo "$WATCHMAN_SHA256 *watchman.tar.gz" | sha256sum -c - \ 36 | && tar -xz -f watchman.tar.gz -C /tmp/ \ 37 | && rm -rf watchman.tar.gz 38 | 39 | # Step 8: Build watchman from source: 40 | RUN cd /tmp/watchman-${WATCHMAN_VERSION} \ 41 | && ./autogen.sh \ 42 | && ./configure --enable-lenient \ 43 | && make \ 44 | && make install \ 45 | && cd $HOME \ 46 | && rm -rf /tmp/* 47 | 48 | # Stage III: Release =========================================================== 49 | 50 | # Step 9: Begin with the runtime stage image: 51 | FROM runtime AS release 52 | 53 | # Step 10: Copy the compiled executable: 54 | COPY --from=builder /usr/local/bin/watchman* /usr/local/bin/ 55 | 56 | # Step 11: Copy the documentation: 57 | COPY --from=builder /usr/local/share/doc/watchman-4.9.0 /usr/local/share/doc/watchman-4.9.0 58 | 59 | # Step 12: Copy the runtime directories: 60 | COPY --from=builder /usr/local/var/run/watchman /usr/local/var/run/watchman 61 | -------------------------------------------------------------------------------- /debian/buster/Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage I: Runtime ============================================================= 2 | 3 | # Step 1: Begin with Debian Buster: 4 | FROM debian:buster AS runtime 5 | 6 | # Step 2: Install watchman runtime dependencies: 7 | RUN apt-get update \ 8 | && apt-get install -y --no-install-recommends \ 9 | libssl1.1 \ 10 | && rm -rf /var/lib/apt/lists/* 11 | 12 | # Stage II: Builder ============================================================ 13 | 14 | # Step 3: Begin from runtime stage image: 15 | FROM runtime AS builder 16 | 17 | # Step 4: Install the watchman build dependencies' dependencies :) 18 | RUN apt-get update \ 19 | && apt-get install -y --no-install-recommends \ 20 | ca-certificates \ 21 | curl \ 22 | openssl \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | # Step 5: Install the watchman build dependencies: 26 | RUN apt-get update \ 27 | && apt-get install -y --no-install-recommends \ 28 | automake \ 29 | autoconf \ 30 | build-essential \ 31 | libtool \ 32 | libssl-dev \ 33 | pkg-config \ 34 | python-dev \ 35 | && rm -rf /var/lib/apt/lists/* 36 | 37 | # Step 6: Set environment variables: 38 | ENV WATCHMAN_VERSION=4.9.0 \ 39 | WATCHMAN_SHA256=1f6402dc70b1d056fffc3748f2fdcecff730d8843bb6936de395b3443ce05322 40 | 41 | # Step 7: Download watchman source code: 42 | RUN cd /tmp \ 43 | && curl --silent --location --output watchman.tar.gz "https://github.com/facebook/watchman/archive/v${WATCHMAN_VERSION}.tar.gz" \ 44 | && echo "$WATCHMAN_SHA256 *watchman.tar.gz" | sha256sum -c - \ 45 | && tar -xz -f watchman.tar.gz -C /tmp/ \ 46 | && rm -rf watchman.tar.gz 47 | 48 | # Step 8: Build watchman from source: 49 | RUN cd /tmp/watchman-${WATCHMAN_VERSION} \ 50 | && ./autogen.sh \ 51 | && ./configure --enable-lenient \ 52 | && make \ 53 | && make install \ 54 | && cd $HOME \ 55 | && rm -rf /tmp/* 56 | 57 | # III: Release stage: ============================================================ 58 | # In this stage, we build the final, deployable Docker image, which will be 59 | # smaller than the images generated on previous stages: 60 | 61 | # Step 9: Begin with the runtime stage image: 62 | FROM runtime AS release 63 | 64 | # Step 10: Copy the compiled executable: 65 | COPY --from=builder /usr/local/bin/watchman* /usr/local/bin/ 66 | 67 | # Step 11: Copy the documentation: 68 | COPY --from=builder /usr/local/share/doc/watchman-4.9.0 /usr/local/share/doc/watchman-4.9.0 69 | 70 | # Step 12: Copy the runtime directories: 71 | COPY --from=builder /usr/local/var/run/watchman /usr/local/var/run/watchman --------------------------------------------------------------------------------