docker: build from the local working directory

With this change, the Dockerfile builds the Docker image from the code
checked out in the local filesystem, instead of downloading a revision
from git.

Implements #3657
pull/3636/head
Pierre Prinetti 2019-11-08 22:56:30 +01:00
parent c008ee36bd
commit dc15f4a43c
3 changed files with 7 additions and 39 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.hg
settings.json
src/node_modules

View File

@ -3,16 +3,10 @@
# https://github.com/ether/etherpad-lite # https://github.com/ether/etherpad-lite
# #
# Author: muxator # Author: muxator
#
# Version 0.1
FROM node:10-buster-slim FROM node:10-buster-slim
LABEL maintainer="Etherpad team, https://github.com/ether/etherpad-lite" LABEL maintainer="Etherpad team, https://github.com/ether/etherpad-lite"
# git hash of the version to be built.
# If not given, build the latest development version.
ARG ETHERPAD_VERSION=develop
# plugins to install while building the container. By default no plugins are # plugins to install while building the container. By default no plugins are
# installed. # installed.
# If given a value, it has to be a space-separated, quoted list of plugin names. # If given a value, it has to be a space-separated, quoted list of plugin names.
@ -25,24 +19,10 @@ ARG ETHERPAD_PLUGINS=
# this can be done with build args (and is mandatory to build ARM version) # this can be done with build args (and is mandatory to build ARM version)
ENV NODE_ENV=development ENV NODE_ENV=development
# grab the ETHERPAD_VERSION tarball from github (no need to clone the whole
# repository)
RUN echo "Getting version: ${ETHERPAD_VERSION}" && \
curl \
--location \
--fail \
--silent \
--show-error \
--output /opt/etherpad-lite.tar.gz \
https://github.com/ether/etherpad-lite/archive/"${ETHERPAD_VERSION}".tar.gz && \
mkdir /opt/etherpad-lite && \
tar xf /opt/etherpad-lite.tar.gz \
--directory /opt/etherpad-lite \
--strip-components=1 && \
rm /opt/etherpad-lite.tar.gz
WORKDIR /opt/etherpad-lite WORKDIR /opt/etherpad-lite
COPY ./ ./
# install node dependencies for Etherpad # install node dependencies for Etherpad
RUN bin/installDeps.sh && \ RUN bin/installDeps.sh && \
rm -rf ~/.npm/_cacache rm -rf ~/.npm/_cacache
@ -54,7 +34,7 @@ RUN bin/installDeps.sh && \
RUN for PLUGIN_NAME in ${ETHERPAD_PLUGINS}; do npm install "${PLUGIN_NAME}"; done RUN for PLUGIN_NAME in ${ETHERPAD_PLUGINS}; do npm install "${PLUGIN_NAME}"; done
# Copy the configuration file. # Copy the configuration file.
COPY ./settings.json /opt/etherpad-lite/ COPY ./docker/settings.json /opt/etherpad-lite/settings.json
# Follow the principle of least privilege: run as unprivileged user. # Follow the principle of least privilege: run as unprivileged user.
# #

View File

@ -35,26 +35,11 @@ Some plugins will need personalized settings in the `settings.json` file. Just r
### Examples ### Examples
Build the latest development version: Build a Docker image from the currently checked-out code:
```bash ```bash
docker build --tag <YOUR_USERNAME>/etherpad . docker build --tag <YOUR_USERNAME>/etherpad .
``` ```
Build the latest stable version:
```bash
docker build --build-arg ETHERPAD_VERSION=master --build-arg NODE_ENV=production --tag <YOUR_USERNAME>/etherpad .
```
Build a specific tagged version:
```bash
docker build --build-arg ETHERPAD_VERSION=1.7.5 --build-arg NODE_ENV=production --tag <YOUR_USERNAME>/etherpad .
```
Build a specific git hash:
```bash
docker build --build-arg ETHERPAD_VERSION=4c45ac3cb1ae --tag <YOUR_USERNAME>/etherpad .
```
Include two plugins in the container: Include two plugins in the container:
```bash ```bash
docker build --build-arg ETHERPAD_PLUGINS="ep_codepad ep_author_neat" --tag <YOUR_USERNAME>/etherpad . docker build --build-arg ETHERPAD_PLUGINS="ep_codepad ep_author_neat" --tag <YOUR_USERNAME>/etherpad .