Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile for local development #904

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ehthumbs.db
# HUGO
/public
/resources
.hugo_build.lock

# Generated client pages
content/download/*.md
Expand Down
158 changes: 9 additions & 149 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,155 +1,15 @@
FROM alpine:latest
MAINTAINER Mathilde Ffrench <[email protected]>

ENV LANG=C.UTF-8 PYTHON_VERSION=2.7.12 PYTHON_PIP_VERSION=8.1.2 HUGO_VERSION=0.16 NODE_VERSION=v6.3.1 NPM_VERSION=3 NODE_CONFIG_FLAGS="--fully-static" NODE_DEL_PKGS="libgcc libstdc++" NODE_RM_DIRS=/usr/include GRMK_PKGNAME=graphicsmagick GRMK_PKGVER=1.3.23
ENV GRMK_PKGSOURCE=https://downloads.sourceforge.net/$GRMK_PKGNAME/$GRMK_PKGNAME/$GRMK_PKGVER/GraphicsMagick-$GRMK_PKGVER.tar.lz

# nats-site dev env - one shoot installer : Python, Hugo, Pygments, GraphicsMagick and Node
RUN set -ex \
&& apk add --update wget ca-certificates \
&& apk add --no-cache --virtual .fetch-deps curl gnupg tar xz \
&& apk add --no-cache --virtual .build-deps \
bzip2-dev \
gcc \
libc-dev \
linux-headers \
make \
ncurses-dev \
openssl-dev \
pax-utils \
readline-dev \
sqlite-dev \
tcl-dev \
tk-dev \
zlib-dev \
&& apk add --update g++ \
gcc \
make \
lzip \
wget \
libjpeg-turbo-dev \
libpng-dev \
libtool \
libgomp \
&& apk add --no-cache curl make gcc g++ linux-headers paxctl libgcc libstdc++ gnupg \

&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& rm -r "$GNUPGHOME" python.tar.xz.asc \

&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
&& cd /usr/src/python \
&& ./configure \
--enable-shared \
--enable-unicode=ucs4 \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \

&& curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
&& [ "$(pip list | awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .python-rundeps $runDeps \

&& cd /tmp/ \
&& wget --no-check-certificate https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tgz \
&& tar xzf hugo_${HUGO_VERSION}_linux-64bit.tgz \
&& rm -r hugo_${HUGO_VERSION}_linux-64bit.tgz \
&& mv hugo /usr/bin/hugo \

&& cd / \
&& pip install Pygments \

&& wget $GRMK_PKGSOURCE \
&& lzip -d -c GraphicsMagick-$GRMK_PKGVER.tar.lz | tar -xvf - \
&& cd GraphicsMagick-$GRMK_PKGVER \
&& ./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localstatedir=/var \
--enable-shared \
--disable-static \
--with-modules \
--with-threads \
--with-gs-font-dir=/usr/share/fonts/Type1 \
--with-quantum-depth=16 \
&& make \
&& make install \
&& cd .. \
&& rm -rf GraphicsMagick-$GRMK_PKGVER \
&& rm GraphicsMagick-$GRMK_PKGVER.tar.lz \

&& curl -o node-${NODE_VERSION}.tar.gz -sSL https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}.tar.gz \
&& curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \
C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
&& gpg --verify SHASUMS256.txt.asc \
&& grep node-${NODE_VERSION}.tar.gz SHASUMS256.txt.asc | sha256sum -c - \
&& tar -zxf node-${NODE_VERSION}.tar.gz \
&& cd node-${NODE_VERSION} \
&& export GYP_DEFINES="linux_use_gold_flags=0" \
&& ./configure --prefix=/usr ${NODE_CONFIG_FLAGS} \
&& NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
&& make -j${NPROC} -C out mksnapshot BUILDTYPE=Release \
&& paxctl -cm out/Release/mksnapshot \
&& make -j${NPROC} \
&& make install \
&& paxctl -cm /usr/bin/node \
&& cd / \
&& if [ -x /usr/bin/npm ]; then \
npm install -g npm@${NPM_VERSION} && \
find /usr/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; \
fi \
&& apk del curl make gcc g++ python linux-headers paxctl gnupg ${NODE_DEL_PKGS} \
&& rm -rf /etc/ssl /node-${VERSION}.tar.gz /SHASUMS256.txt.asc /node-${NODE_VERSION} ${NODE_RM_DIRS} \
/usr/share/man /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp /root/.gnupg \
/usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html \
&& apk del wget ca-certificates
FROM node:current-alpine

RUN apk add --update hugo

VOLUME /nats-site

WORKDIR /nats-site

EXPOSE 1313
COPY package.json /nats-site/package.json
COPY package-lock.json /nats-site/package-lock.json
COPY yarn.lock /nats-site/yarn.lock
RUN npm install

CMD ["/usr/bin/hugo", "server", "-w", "--bind", "0.0.0.0"]
EXPOSE 1313
ENTRYPOINT [""]
CMD ["/usr/bin/hugo", "server", "-D", "-w", "--bind", "0.0.0.0"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ netlify-production-build: generate-client-pages

netlify-preview-build: generate-client-pages
hugo --baseURL $(DEPLOY_PRIME_URL) --buildDrafts --buildFuture

docker:
@echo "\033[0;32m Building and running NATS Website ... \033[0m"
docker build -t nats-site .
docker run --rm -p 1313:1313 -v ${PWD}:/nats-site nats-site
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ If you are a production end user of NATS and would like your company logo displa

## Local Development

You can either use docker image for your local development or install requirements following this documentation.

You can either use docker image for your local development via `make docker` or install requirements following this documentation.

Clone your forked copy of the repository:
```
Expand All @@ -195,7 +194,7 @@ Install [Hugo](https://gohugo.io/), [npm](https://docs.npmjs.com/getting-started

#### Building the Site

See the makefile for run commands.
See the [Makefile](./Makefile) for other commands.


Thank you for your interest in NATS!