Skip to content

Draft: Replacing own script with docker-compose #25

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

Open
wants to merge 8 commits into
base: master
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
79 changes: 79 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -------------------------------------------------------------------------
# _____ _ _ _____ _ _ _
# | ___| (_) | | ___ | ___| (_) __ _ | |__ | |_ ___ _ __
# | |_ | | | | / _ \ | |_ | | / _ | | '_ \ | __| / _ \ | '__|
# | _| | | | | | __/ | _| | | | (_| | | | | | | |_ | __/ | |
# |_| |_| |_| \___| |_| |_| \__, | |_| |_| \__| \___| |_|
# |___/
#
# This is the FileFighter config file
#
# When running docker-compose up the values of these keys will be inserted
# into the docker-compose.yml file
#
# -------------------------------------------------------------------------
# General Settings:
#
# can be: no, on-failure[:max-retries], always, unless-stopped
RESTART_POLICY=unless-stopped

# specifies which kind of release to use
# can be: latest, stable
RELEASE_CHANNEL=stable

# -------------------------------------------------------------------------
# Frontend Settings:
#
# the port for the FileFighter Frontend.
# can be any valid port
FRONTEND_PORT=80

# the origin of the application.
# TODO: Change this to the url that will be used to access filefighter with
# a browser (add port if using non standard ports)
FRONTEND_ORIGIN=http://localhost

# -------------------------------------------------------------------------
# Database Settings:
#
# the name of the local data directory for the database
DB_VOLUME=./database

# name of the database, can be whatever you want to be
DB_NAME=filefighter

# database username for the other services
DB_USERNAME=root

# database password for the user
# TODO: Change this to something secure
DB_PASSWORD=admin

# -------------------------------------------------------------------------
# Filehandler Settings:
#
# the name of the local data directory for the filehandler
FILEHANDLER_VOLUME=./filehandler


# TODO: Change this to something secure to enable encryption
# leave or set it to null to not use encryption
ENCRYPTION_PASSWORD=null

# TODO: When using encryption these settings are relevant

# database user name used for the filehandler application
FH_DB_USERNAME=filehandler

# database name used for the filehandler application
FH_DB_NAME=filehandler

# database password used for the filehandler application
FH_DB_PASSWORD=secure

# -------------------------------------------------------------------------
# Filesystemservice Settings:
#
# secret used to sign jwts
# TODO: change this to something secure
JWT_SECRET=s3cr3t
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
.idea
*.log
tmp/


# volumes
database/
filehandler/
25 changes: 0 additions & 25 deletions Download.sh

This file was deleted.

43 changes: 0 additions & 43 deletions Install.sh

This file was deleted.

5 changes: 0 additions & 5 deletions config.cfg

This file was deleted.

106 changes: 83 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,101 @@
# -------------------------------------------------------------------------
# _____ _ _ _____ _ _ _
# | ___| (_) | | ___ | ___| (_) __ _ | |__ | |_ ___ _ __
# | |_ | | | | / _ \ | |_ | | / _ | | '_ \ | __| / _ \ | '__|
# | _| | | | | | __/ | _| | | | (_| | | | | | | |_ | __/ | |
# |_| |_| |_| \___| |_| |_| \__, | |_| |_| \__| \___| |_|
# |___/
#
# This is the FileFighter docker-compose file
#
# DO NOT CHANGE THIS FILE DIRECTY (unless you know what you are doing)!
# If you want to configure your instance of FileFighter edit the .env file.
#
# Starting FileFighter:
# docker-compose up -d
#
# -------------------------------------------------------------------------
version: "3.3"
services:
FileFighterFrontend:
image: filefighter/frontend:stable
frontend:
image: filefighter/frontend:feature
ports:
- ${FRONTEND_PORT}:80
depends_on:
- fss
- filehandler
networks:
- FileFighterNetwork
depends_on:
- FileFighterREST
- FileFighterFileHandler
ports:
- "80:80"
FileFighterREST:
image: filefighter/rest:stable
restart: ${RESTART_POLICY}

fss:
image: filefighter/filesystemservice:feature
environment:
DB_USERNAME: root
DB_PASSWORD: GUZFDEGFIDGSZGFZGZDGSZ #change this
DB_NAME: filefighter
DB_CONTAINER_NAME: FileFighterDB
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
DB_NAME: ${DB_NAME}
DB_CONTAINER_NAME: db
JWT_SECRET: ${JWT_SECRET}
FRONTEND_ORIGIN: ${FRONTEND_ORIGIN} # FIXME: This option is ignored by spring
SPRING_PROFILES_ACTIVE: "prod"
expose:
- "8080"
depends_on:
- FileFighterDB
- db
networks:
- FileFighterNetwork
FileFighterDB:
restart: ${RESTART_POLICY}

db:
image: mongo:latest
environment:
MONGO_INITDB: filefighter
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: GUZFDEGFIDGSZGFZGZDGSZ #change this
MONGO_INITDB: ${DB_NAME}
MONGO_INITDB_ROOT_USERNAME: ${DB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${DB_PASSWORD}
FH_DB_USERNAME: ${FH_DB_USERNAME}
FH_DB_PASSWORD: ${FH_DB_PASSWORD}
FH_DB_NAME: ${FH_DB_NAME}
networks:
- FileFighterNetwork
FileFighterFileHandler:
image: filefighter/filehandler:stable
volumes:
- ${DB_VOLUME}:/data/db
- ./docker-entrypoint-initdb.d/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh:ro
restart: ${RESTART_POLICY}

filehandler:
image: filefighter/filehandler:feature
environment:
DB_USERNAME: ${FH_DB_USERNAME}
DB_PASSWORD: ${FH_DB_PASSWORD}
DB_NAME: ${FH_DB_NAME}
DB_CONTAINER_NAME: db
FILESYSTEMSERVICE_URL: fss
FILESYSTEMSERVICE_PORT: 8080
ENCRYPTION_PASSWORD: ${ENCRYPTION_PASSWORD}
FRONTEND_ORIGIN: ${FRONTEND_ORIGIN}
depends_on:
- fss
networks:
- FileFighterNetwork
volumes:
- ${FILEHANDLER_VOLUME}:/workdir
restart: ${RESTART_POLICY}

ftp-service:
image: filefighter/ftp-service:${RELEASE_CHANNEL}
environment:
# TODO: remove after fixing the paths in fss
FTP_SERVICE_BACKEND_URL: http://fss:8080/api
FTP_SERVICE_FILEHANDLER_URL: http://filehandler:5000
# IDEA: make this customizable
# IDEA: implement tls for ftp?
ports:
- "2121:2121"
- "10000-10010:10000-10010"
depends_on:
- FileFighterREST
- fss
- filehandler
networks:
- FileFighterNetwork
restart: ${RESTART_POLICY}

networks:
FileFighterNetwork:
34 changes: 22 additions & 12 deletions lib/utils.sh → docker-entrypoint-initdb.d/init-mongo.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
set -e

echoLogo() {
echo " _____ _ _ _____ _ _ _ "
echo " | ___| (_) | | ___ | ___| (_) __ _ | |__ | |_ ___ _ __ "
echo " | |_ | | | | / _ \ | |_ | | / _\` | | '_ \ | __| / _ \ | '__|"
echo " | _| | | | | | __/ | _| | | | (_| | | | | | | |_ | __/ | | "
echo " |_| |_| |_| \___| |_| |_| \__, | |_| |_| \__| \___| |_| "
echo " |___/ "
echo " Version $1 Last updated: $2"
echo " Developed by Gimleux, Valentin, Open-Schnick. "
echo " Development Blog: https://blog.filefighter.de "
echo " The code can be found at: https://www.github.com/filefighter "
echo ""
echo "-------------------------< $3 >---------------------------"
echo "-------------------------< DB SETUP >---------------------------"
echo ""
}

printUsage() {
echo "usage: ffighter <args>"
echo ""
echo " status - show status of the FileFighter application."
echo " install - install the FileFighter application."
echo " start - start the services."
echo " stop - stop the services."
echo " remove - remove all services."
echo " update - update all the services that have a new version available."
}
echoLogo

echo "Adding users with init script"

echo "Adding user $FH_DB_USERNAME to db $FH_DB_NAME"

mongo <<EOF

print("Started Adding the Users.");
db = db.getSiblingDB('$FH_DB_NAME');
print("Adding FH user to db:" , db);
db.createUser({
user: '$FH_DB_USERNAME',
pwd: '$FH_DB_PASSWORD',
roles: [{ role: "readWrite", db: '$FH_DB_NAME' }],
});
print("End Adding the Users.");

EOF
Loading