diff --git a/MooseFS/docker-compose.yml b/MooseFS/docker-compose.yml new file mode 100644 index 0000000..2f87aa6 --- /dev/null +++ b/MooseFS/docker-compose.yml @@ -0,0 +1,145 @@ +version: '3' +services: + mfsmaster: + build: ./moosefs-master + container_name: "mfsmaster" + networks: + moosefsnet: + ipv4_address: "172.23.0.2" + volumes: + - ./data/master/meta:/var/lib/mfs + hostname: mfsmaster + environment: + - MFS_ENV=TEST + # In the TEST environment, if metadata.mfs file or other metadata files + # like metdata.mfs.back and changelog.0.mfs are missing, the script will + # create an EMPTY metadata file! + # When MFS_ENV=PROD metdata.mfs file will not be created! + + mfscgi: + build: ./moosefs-cgi + container_name: "mfscgi" + networks: + moosefsnet: + ipv4_address: "172.23.0.3" + ports: + - "9425:9425" + depends_on: + - mfsmaster + + mfsmetalogger: + build: ./moosefs-metalogger + container_name: "mfsmetalogger" + networks: + moosefsnet: + ipv4_address: "172.23.0.4" + volumes: + - ./data/metalogger/meta:/var/lib/mfs + environment: + - MFS_ENV=TEST + # In the TEST environment, if metadata.mfs file or other metadata files + # like metdata.mfs.back and changelog.0.mfs are missing, the script will + # create an EMPTY metadata file! + # When MFS_ENV=PROD metdata.mfs file will not be created! + depends_on: + - mfsmaster + + mfschunkserver1: + build: ./moosefs-chunkserver + container_name: "mfschunkserver1" + environment: + - LABELS=M + #- SIZE=100 + links: + - mfsmaster + # env_file: + # - ./env.list + networks: + moosefsnet: + ipv4_address: "172.23.0.11" + volumes: + - ./data/cs1/hdd0:/mnt/hdd0 + - ./data/cs1/meta:/var/lib/mfs + depends_on: + - mfsmaster + mfschunkserver2: + build: ./moosefs-chunkserver + container_name: "mfschunkserver2" + environment: + - LABELS=M,B + #- SIZE=100 + links: + - mfsmaster + # env_file: + # - ./env.list + networks: + moosefsnet: + ipv4_address: "172.23.0.12" + volumes: + - ./data/cs2/hdd0:/mnt/hdd0 + - ./data/cs2/meta:/var/lib/mfs + depends_on: + - mfsmaster + weba: + build: ./weba + container_name: weba + volumes: + - ./data/cs1/hdd0:/mnt/hdd0 + - ./data/cs1/meta:/var/lib/mfs + ports: + - "6002:6000" + links: + - mfsmaster + networks: + moosefsnet: + ipv4_address: "172.23.0.13" + depends_on: + - mfschunkserver1 + # - chunkserver2 + # restart: always + + webb: + build: ./webb + container_name: webb + volumes: + - ./data/cs2/hdd0:/mnt/hdd0 + - ./data/cs2/meta:/var/lib/mfs + ports: + - "6001:6000" + links: + - mfsmaster + networks: + moosefsnet: + ipv4_address: "172.23.0.14" + depends_on: + # - chunkserver1 + - mfschunkserver2 + mfsclient: + build: ./moosefs-client + container_name: "mfsclient" + cap_add: + - SYS_ADMIN + devices: + - /dev/fuse:/dev/fuse + security_opt: + - apparmor:unconfined + stdin_open: true + tty: true + links: + - mfsmaster + networks: + moosefsnet: + ipv4_address: "172.23.0.100" + depends_on: + - mfsmaster + - mfschunkserver1 + - mfschunkserver2 + # - mfschunkserver3 + # - mfschunkserver4 + +networks: + moosefsnet: + driver: bridge + ipam: + config: + - subnet: 172.23.0.0/16 diff --git a/MooseFS/dockerfile b/MooseFS/dockerfile new file mode 100644 index 0000000..fe65827 --- /dev/null +++ b/MooseFS/dockerfile @@ -0,0 +1,11 @@ +FROM python:3.8-slim-buster + +RUN mkdir /app +WORKDIR /app + +COPY requirements.txt . +RUN pip3 install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python3", "app.py" ] diff --git a/MooseFS/moosefs-cgi/Dockerfile b/MooseFS/moosefs-cgi/Dockerfile new file mode 100644 index 0000000..cee130d --- /dev/null +++ b/MooseFS/moosefs-cgi/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:buster + +# Install wget and gnupg2 +RUN apt-get update && apt-get install -y wget gnupg2 python3 + +# Add key +RUN wget -O - http://ppa.moosefs.com/moosefs.key 2>/dev/null | apt-key add - 2>/dev/null +RUN echo "deb http://ppa.moosefs.com/3.0.115/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list + +# Install MooseFS master +RUN apt-get update && apt-get install -y moosefs-cgi moosefs-cgiserv moosefs-cli dos2unix + +# Expose ports master ports +EXPOSE 9425 + +# Add start script +ADD cgiserver.sh /usr/sbin/cgiserver.sh +RUN chown root:root /usr/sbin/cgiserver.sh ; chmod 700 /usr/sbin/cgiserver.sh +RUN dos2unix /usr/sbin/cgiserver.sh +CMD ["cgiserver.sh"] diff --git a/MooseFS/moosefs-cgi/cgiserver.sh b/MooseFS/moosefs-cgi/cgiserver.sh new file mode 100644 index 0000000..134de0a --- /dev/null +++ b/MooseFS/moosefs-cgi/cgiserver.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +CMD="mfscgiserv -f" + +#Add host if set +if [ ! -z ${MASTER_HOST+X} ]; + then + CMD="$CMD -H $MASTER_HOST" +fi + +#Add host if set +if [ ! -z ${MASTER_PORT+X} ]; + then + CMD="$CMD -P $MASTER_PORT" +fi + +exec $CMD diff --git a/MooseFS/moosefs-chunkserver/Dockerfile b/MooseFS/moosefs-chunkserver/Dockerfile new file mode 100644 index 0000000..9d9a244 --- /dev/null +++ b/MooseFS/moosefs-chunkserver/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:buster + +# Install wget, lsb-release and curl +RUN apt-get update && apt-get install -y wget gnupg2 gettext-base + +# Add key +RUN wget -O - http://ppa.moosefs.com/moosefs.key 2>/dev/null | apt-key add - 2>/dev/null +RUN echo "deb http://ppa.moosefs.com/3.0.115/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list + +# Install MooseFS chunkserver +RUN apt-get update && apt-get install -y moosefs-chunkserver dos2unix + +# Expose ports +EXPOSE 9422 + +# Add start script +ADD chunkserver.sh /usr/sbin/chunkserver.sh +RUN chown root:root /usr/sbin/chunkserver.sh ; chmod 700 /usr/sbin/chunkserver.sh ; mkdir -p /mnt/hdd0 +RUN dos2unix /usr/sbin/chunkserver.sh +CMD ["chunkserver.sh"] diff --git a/MooseFS/moosefs-chunkserver/chunkserver.sh b/MooseFS/moosefs-chunkserver/chunkserver.sh new file mode 100644 index 0000000..028f072 --- /dev/null +++ b/MooseFS/moosefs-chunkserver/chunkserver.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +mkdir -p /mnt/hdd0/mfs +# Set correct owner +chown -R mfs:mfs /mnt/hdd0 /mnt/hdd0/mfs /var/lib/mfs + +# Overwrite mfschunkserver.cfg if passed in +# this will base64 decode MFS_CHUNKSERVER_CONFIG variable text +# substitute any env variables in decoded text +# save text into /etc/mfs/mfschunkserver.cfg +if [ ! -z ${MFS_CHUNKSERVER_CONFIG+X} ]; + then + echo $MFS_CHUNKSERVER_CONFIG | base64 -d | envsubst > /etc/mfs/mfschunkserver.cfg +fi + +# Overwrite mfshdd.cfg if passed in +# this will base64 decode MFS_HDD_CONFIG variable text +# substitute any env variables in decoded text +# save text into /etc/mfs/mfshdd.cfg +if [ ! -z ${MFS_HDD_CONFIG+X} ]; + then + echo $MFS_HDD_CONFIG | base64 -d | envsubst > /etc/mfs/mfshdd.cfg +fi + + +#Add size to hdd if defined +if [ -z ${SIZE+X} ]; + then + echo "/mnt/hdd0" > /etc/mfs/mfshdd.cfg + else + echo "/mnt/hdd0 ${SIZE}GiB" > /etc/mfs/mfshdd.cfg +fi + +# Add label if defined +if [ ! -z ${LABELS+X} ]; + then + echo "LABELS=$LABELS" >> /etc/mfs/mfschunkserver.cfg +fi + +if [ ! -z ${MASTER_HOST+X} ]; + then + echo "MASTER_HOST=$MASTER_HOST" >> /etc/mfs/mfschunkserver.cfg +fi +if [ ! -z ${CSSERV_LISTEN_PORT+X} ]; + then + echo "CSSERV_LISTEN_PORT=$CSSERV_LISTEN_PORT" >> /etc/mfs/mfschunkserver.cfg +fi +if [ ! -z ${DATA_PATH+X} ]; + then + echo "DATA_PATH=$DATA_PATH" >> /etc/mfs/mfschunkserver.cfg +fi + +exec mfschunkserver -f diff --git a/MooseFS/moosefs-chunkserver/mfschunkserver.cfg b/MooseFS/moosefs-chunkserver/mfschunkserver.cfg new file mode 100644 index 0000000..9596915 --- /dev/null +++ b/MooseFS/moosefs-chunkserver/mfschunkserver.cfg @@ -0,0 +1,16 @@ +# Use the hostname or IP address of the MooseFS master server +MASTER_HOST = "172.23.0.2" + +# Use the port number of the MooseFS master server (default is 9419) +MASTER_PORT = 9419 + +# Use the labels for this chunkserver (M, B, L, R, etc.) +LABELS = M,B + +# Use the IP address or hostname of this chunkserver +CSSERV_LISTEN_HOST = "172.23.0.11" , "172.23.0.12" + +# Use the port number of this chunkserver (default is 9420) +CSSERV_LISTEN_PORT = 9420 + +DATA_PATH = /mnt/hdd0 diff --git a/MooseFS/moosefs-client/Dockerfile b/MooseFS/moosefs-client/Dockerfile new file mode 100644 index 0000000..2a7a631 --- /dev/null +++ b/MooseFS/moosefs-client/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:buster + +# Install libraries +RUN apt-get update && apt-get install -y wget fuse3 libfuse3-3 gnupg2 python3 + +# Add key +RUN wget -O - http://ppa.moosefs.com/moosefs.key 2>/dev/null | apt-key add - 2>/dev/null +RUN echo "deb http://ppa.moosefs.com/3.0.115/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list + +# Install MooseFS client and cli +RUN apt-get update && apt-get install -y moosefs-client moosefs-cli dos2unix + +# Add start script +ADD mount.sh /usr/sbin/mount.sh +RUN chown root:root /usr/sbin/mount.sh ; chmod 700 /usr/sbin/mount.sh ; mkdir -p /mnt/moosefs +RUN dos2unix /usr/sbin/mount.sh +CMD ["mount.sh"] diff --git a/MooseFS/moosefs-client/mount.sh b/MooseFS/moosefs-client/mount.sh new file mode 100644 index 0000000..878b120 --- /dev/null +++ b/MooseFS/moosefs-client/mount.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +CMD="mfsmount /mnt/moosefs -f" + +#Add host if set +if [ ! -z ${MASTER_HOST+X} ]; + then + CMD="$CMD -H $MASTER_HOST" +fi + +#Add host if set +if [ ! -z ${MASTER_PORT+X} ]; + then + CMD="$CMD -P $MASTER_PORT" +fi + +exec $CMD diff --git a/MooseFS/moosefs-master/Dockerfile b/MooseFS/moosefs-master/Dockerfile new file mode 100644 index 0000000..5753adc --- /dev/null +++ b/MooseFS/moosefs-master/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:buster + +# Install wget and gnupg2 +RUN apt-get update && apt-get install -y wget gnupg2 + +# Add key +RUN wget -O - http://ppa.moosefs.com/moosefs.key 2>/dev/null | apt-key add - 2>/dev/null +RUN echo "deb http://ppa.moosefs.com/3.0.115/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list + +# Install MooseFS master +RUN apt-get update && apt-get install -y moosefs-master dos2unix + +# Expose ports master ports +EXPOSE 9419 9420 9421 + +# Add and run start script +ADD master.sh /usr/sbin/master.sh +RUN chown root:root /usr/sbin/master.sh ; chmod 700 /usr/sbin/master.sh +RUN dos2unix /usr/sbin/master.sh +CMD ["master.sh"] diff --git a/MooseFS/moosefs-master/master.sh b/MooseFS/moosefs-master/master.sh new file mode 100644 index 0000000..ed84439 --- /dev/null +++ b/MooseFS/moosefs-master/master.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Set default MooseFS enviroment to PRODUCTION +MFS_ENV="${MFS_ENV:-PROD}" + +#Set correct owner +chown -R mfs:mfs /var/lib/mfs + +# Overwrite mfsmaster.cfg if passed in +# this will base64 decode MFS_MASTER_CONFIG variable text +# substitute any env variables in decoded text +# save text into /etc/mfs/mfsmaster.cfg +if [ ! -z ${MFS_MASTER_CONFIG+X} ]; + then + echo $MFS_MASTER_CONFIG | base64 -d | envsubst > /etc/mfs/mfsmaster.cfg +fi + +# We have to be sure that we have metadata files +if [ -f /var/lib/mfs/metadata.mfs ]; +then + exec mfsmaster -f +else + if [[ -f /var/lib/mfs/metadata.mfs.back.1 && -f /var/lib/mfs/changelog.0.mfs ]]; + then + echo "Can't find metadata.mfs file" + echo "Let's try to restore it" + exec mfsmaster -a -f + else + if [ "$MFS_ENV" == "TEST" ]; + then + echo "MFSM NEW" > /var/lib/mfs/metadata.mfs + exec mfsmaster -f + else + echo "No /var/lib/mfs/metadata.mfs file!" + echo "EXITING - THIS IS A PRODUCTION ENVIRONMENT!" + exit 1 + fi + fi +fi diff --git a/MooseFS/moosefs-metalogger/Dockerfile b/MooseFS/moosefs-metalogger/Dockerfile new file mode 100644 index 0000000..2c8b559 --- /dev/null +++ b/MooseFS/moosefs-metalogger/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:buster + +# Install wget and gnupg2 +RUN apt-get update && apt-get install -y wget gnupg2 gettext-base + +# Add key +RUN wget -O - http://ppa.moosefs.com/moosefs.key 2>/dev/null | apt-key add - 2>/dev/null +RUN echo "deb http://ppa.moosefs.com/3.0.115/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list + +# Install MooseFS metalogger +RUN apt-get update && apt-get install -y moosefs-metalogger dos2unix + +# Add and run start script +ADD metalogger.sh /usr/sbin/metalogger.sh +RUN chown root:root /usr/sbin/metalogger.sh ; chmod 700 /usr/sbin/metalogger.sh +RUN dos2unix /usr/sbin/metalogger.sh +CMD ["metalogger.sh"] diff --git a/MooseFS/moosefs-metalogger/metalogger.sh b/MooseFS/moosefs-metalogger/metalogger.sh new file mode 100644 index 0000000..82c1f14 --- /dev/null +++ b/MooseFS/moosefs-metalogger/metalogger.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# Set default MooseFS enviroment to PRODUCTION +MFS_ENV="${MFS_ENV:-PROD}" + +# Set a correct owner +chown -R mfs:mfs /var/lib/mfs + +# Overwrite mfsmetalogger.cfg if passed in +# this will base64 decode MFS_METALOGGER_CONFIG variable text +# substitute any env variables in decoded text +# save text into /etc/mfs/mfsmetalogger.cfg +if [ ! -z ${MFS_METALOGGER_CONFIG+X} ]; + then + echo $MFS_METALOGGER_CONFIG | base64 -d | envsubst > /etc/mfs/mfsmetalogger.cfg +fi + +# Run +exec mfsmetalogger -f diff --git a/MooseFS/requirements.txt b/MooseFS/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/MooseFS/weba/app.py b/MooseFS/weba/app.py new file mode 100644 index 0000000..7141f3c --- /dev/null +++ b/MooseFS/weba/app.py @@ -0,0 +1,13 @@ +import os + +path = "/var/lib/mfs/test.txt" + +if not os.path.exists(os.path.dirname(path)): + os.makedirs(os.path.dirname(path)) + +with open(path, "w") as f: + f.write("Hello World! from webA") + + +if __name__ == "__main__": + print("File written successfully from webA!") diff --git a/MooseFS/weba/dockerfile b/MooseFS/weba/dockerfile new file mode 100644 index 0000000..d5e6ac7 --- /dev/null +++ b/MooseFS/weba/dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9 +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +CMD [ "python", "app.py", "write" ] diff --git a/MooseFS/weba/requirements.txt b/MooseFS/weba/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/MooseFS/webb/app.py b/MooseFS/webb/app.py new file mode 100644 index 0000000..763f6d7 --- /dev/null +++ b/MooseFS/webb/app.py @@ -0,0 +1,17 @@ +import os + +path = "/var/lib/mfs/test.txt" + +# if not os.path.exists(os.path.dirname(path)): +# os.makedirs(os.path.dirname(path)) + +if os.path.exists(path): + with open(path, "r") as f: + print(f.read()) + os.remove(path) +else: + print("File not found!") + + +if __name__ == "__main__": + print("File read successfully from webB!") diff --git a/MooseFS/webb/dockerfile b/MooseFS/webb/dockerfile new file mode 100644 index 0000000..062c8d0 --- /dev/null +++ b/MooseFS/webb/dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9 +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +CMD [ "python", "app.py", "read" ] diff --git a/MooseFS/webb/requirements.txt b/MooseFS/webb/requirements.txt new file mode 100644 index 0000000..e69de29