improved dockerfiles

They do not use git pull to get the latest YaCy code.
Instead they copy from local file system.
pull/402/head
Michael Peter Christen 4 years ago
parent 4c920d05b5
commit 062111a003

@ -15,28 +15,27 @@ RUN java -version
WORKDIR /opt
# All in one step to reduce image size growth :
# - install ant and git packages
# - clone main YaCy git repository (we need to clone git repository to generate correct version when building from source)
# - install ant package
# - Compile with ant
# - remove unnecessary and size consuming .git directory
# - remove ant and git packages
# - remove ant package
# Possible alternative : copy directly your current sources an remove git clone command from the following RUN
# COPY . /opt/yacy_search_server/
# copy sources
COPY . /opt/yacy_search_server/
RUN apt-get update && \
apt-get install -yq ant git && \
git clone https://github.com/yacy/yacy_search_server.git && \
RUN rm -rf /opt/yacy_search_server/.git && \
apt-get update && \
apt-get install -yq ant && \
ant compile -f /opt/yacy_search_server/build.xml && \
rm -rf /opt/yacy_search_server/.git && \
apt-get purge -yq --auto-remove ant git && \
apt-get purge -yq --auto-remove ant && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN \
# Set initial admin password : "docker" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex())
# Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex())
# > java -classpath classes net.yacy.cora.order.Digest -strfhex "admin:The YaCy access is limited to administrators. If you don't know the password, you can change it using <yacy-home>/bin/passwd.sh <new-password>:docker"
sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:e672161ffdce91be4678605f4f4e6786" /opt/yacy_search_server/defaults/yacy.init && \
sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \
sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \
# Intially enable HTTPS: this is the most secure option for remote administrator authentication
sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init && \
# Create user and group yacy: this user will be used to run YaCy main process

@ -77,25 +77,21 @@ ENV PATH ${PATH}:/opt/ant/bin
WORKDIR /opt
# All in one step to reduce image size growth :
# - add git package
# - clone main YaCy git repository (we need to clone git repository to generate correct version when building from source)
# - compile with apache ant
# - remove unnecessary and size consuming .git directory
# - delete git package and ant binary install
# - delete ant binary install
# Possible alternative : copy directly your current sources an remove git clone command from the following RUN
# COPY . /opt/yacy_search_server/
# copy sources
COPY . /opt/yacy_search_server/
RUN apk add --no-cache git && \
git clone https://github.com/yacy/yacy_search_server.git && \
RUN apk add --no-cache \
ant compile -f /opt/yacy_search_server/build.xml && \
rm -rf /opt/yacy_search_server/.git && \
rm -rf /opt/ant && \
apk del git
rm -rf /opt/ant
RUN \
# Set initial admin password : "docker" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex())
sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:e672161ffdce91be4678605f4f4e6786" /opt/yacy_search_server/defaults/yacy.init && \
# Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex())
sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \
sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \
# Intially enable HTTPS: this is the most secure option for remote administrator authentication
sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init && \
# Create user and group yacy: this user will be used to run YaCy main process
@ -103,10 +99,12 @@ RUN \
# Set ownership of yacy install directory to yacy user/group
chown yacy:yacy -R /opt/yacy_search_server
RUN rm -rf /opt/yacy_search_server/DATA
# Expose HTTP and HTTPS default ports
EXPOSE 8090 8443
# Set data volume : yacy data and configuration will persist aven after container stop or destruction
# Set data volume: yacy data and configuration will persist even after container stop or destruction
VOLUME ["/opt/yacy_search_server/DATA"]
# Next commands run as yacy as non-root user for improved security

@ -7,40 +7,45 @@
## Getting built image from Docker Hub
docker pull yacy/yacy_search_server
The repository URL is https://hub.docker.com/r/yacy/yacy_search_server/
Repository URL : (https://hub.docker.com/r/yacy/yacy_search_server/)
* ubuntu-based: `docker pull yacy/yacy_search_server:latest`
* alpine-based: `docker pull yacy/yacy_search_server:latest-alpine`
## Building image yourself
Using yacy_search_server/docker/Dockerfile :
## Building image yourself
Using files in 'yacy_search_server/docker/':
```
cd yacy_search_server/docker
docker build .
```
To build the Alpine variant :
Then according to the image type:
* for ubuntu-based images:
cd yacy_search_server/docker
docker build -f Dockerfile.alpine .
## Image variants
```
docker build -t yacy/yacy_search_server:latest -f Dockerfile ../
```
`yacy/yacy_search_server:latest`
* To build the Alpine variant:
This image is based on latest stable official Debian stable [openjdk](https://hub.docker.com/_/openjdk/) 8 image provided by Docker. Embed Yacy compiled from latest git repository sources.
```
docker build -t yacy/yacy_search_server:alpine-latest -f Dockerfile.alpine ../
```
`yacy/yacy_search_server:latest-alpine`
## Image variants
This image is based on latest stable official Alpine Linux [openjdk](https://hub.docker.com/_/openjdk/) 8 image provided by Docker. Embed Yacy compiled from latest git repository sources.
* `yacy/yacy_search_server:latest`: This image is based on latest stable official Debian stable [openjdk](https://hub.docker.com/_/openjdk/) 8 image provided by Docker. Embed Yacy compiled from latest git repository sources.
* `yacy/yacy_search_server:latest-alpine`: This image is based on latest stable official Alpine Linux [openjdk](https://hub.docker.com/_/openjdk/) 8 image provided by Docker. Embed Yacy compiled from latest git repository sources.
## Default admin account
login : admin
password : docker
* login: admin
* password: yacy
You should modify this default password with page /ConfigAccounts_p.html when exposing publicly your YaCy container.
## Usage
### First start
@ -49,7 +54,7 @@ You should modify this default password with page /ConfigAccounts_p.html when ex
docker run yacy/yacy_search_server
YaCy web interface is then exposed at http://[container_ip]:8090.
YaCy web interface is then exposed at http://[container_ip]:8090
You can retrieve the container IP address with `docker inspect`.
#### Easier to handle
@ -162,7 +167,6 @@ Stop old container :
docker exec [container_name] /opt/yacy_search_server/stopYACY.sh
Start new container:
docker start [tmp-container_name]
@ -178,4 +182,3 @@ Rename new container to reuse same container name :
## License
View [license](https://github.com/yacy/yacy_search_server/blob/master/COPYRIGHT) information for the software contained in this image.

Loading…
Cancel
Save