-
Notifications
You must be signed in to change notification settings - Fork 169
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
Preloading Modules / Dockerization of FAME / Dockerception (combined PR of all changes, do not merge!) #67
base: master
Are you sure you want to change the base?
Changes from all commits
06da9ab
4861433
3340d70
d2984a0
27ece3c
caa615f
2366265
56b5056
605db70
0c23514
4b81f81
a55a41a
b522d5d
1e3f93a
ebc2f69
9ecbb91
055ff83
d98ca75
891643a
4c2bef1
4ffc0c3
c0fbe59
dce2691
51c7396
1d4ae7a
56c6854
d71893b
d231c59
b734ab3
c4342c3
a794a88
361f9cb
13469d4
3bc582f
8547eda
0ada515
c6cc72d
5cf8db2
97f4f4b
e2eb1e1
11a0615
59ee23a
97a1743
635f6ba
676a76f
d8d3c4d
26691dc
680b31a
9ceb492
fc4a928
ebdbd7d
93412e0
e6de6a1
a26b121
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:2-slim-stretch | ||
|
||
RUN apt-get update && apt-get install -y git libmagic1 && \ | ||
useradd -s /bin/false -U fame -m && \ | ||
pip install --no-cache-dir virtualenv && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . /fame | ||
COPY docker/fame/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
|
||
WORKDIR /fame | ||
RUN utils/run.sh -m pip install --no-cache-dir -r requirements.txt | ||
|
||
ENV FAME_DOCKER=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
VOLUME [ "/fame/conf" ] | ||
|
||
ENTRYPOINT [ "docker-entrypoint.sh" ] | ||
CMD [ "/bin/bash" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM fame-base | ||
|
||
ENV FAME_WORKER=0 | ||
|
||
COPY docker/fame/run.web.sh /fame/run.sh | ||
|
||
RUN apt-get update && apt-get install -y libldap2-dev libsasl2-dev build-essential && \ | ||
utils/run.sh -m pip install --no-cache-dir -r requirements-web.txt uwsgi && \ | ||
apt-get purge -y libldap2-dev libsasl2-dev build-essential && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
EXPOSE 8080 | ||
|
||
VOLUME [ "/fame/fame/modules", "/fame/storage", "/fame/web/static/img/avatars" ] | ||
|
||
CMD [ "/fame/run.sh" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM fame-base | ||
|
||
ENV FAME_WORKER=1 | ||
|
||
RUN apt-get update -y && apt-get install -y build-essential && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
git config --global user.name "FAME Web" && \ | ||
git config --global user.email "[email protected]" | ||
|
||
COPY docker/fame/run.worker.sh /fame/run.sh | ||
|
||
RUN utils/run.sh -m pip install --no-cache-dir -r requirements-worker.txt | ||
|
||
CMD [ "/fame/run.sh" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.DEFAULT_GOAL := all | ||
|
||
mongo: | ||
docker build --pull -t fame-mongo docker/mongo/ | ||
|
||
base: | ||
docker build --pull -t fame-base -f Dockerfile.base . | ||
|
||
web: base | ||
docker build -t fame-web -f Dockerfile.web . | ||
|
||
worker: base | ||
docker build -t fame-worker -f Dockerfile.worker . | ||
|
||
all: mongo base web worker |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
version: '3.4' | ||
|
||
networks: | ||
fame_internal: | ||
internal: true | ||
|
||
gateway: | ||
|
||
traefik_default: | ||
external: | ||
name: traefik_default | ||
|
||
x-mongo-env: &mongo_env | ||
MONGO_HOST: "fame-mongo" | ||
MONGO_PORT: "27017" | ||
MONGO_DB: "fame" | ||
MONGO_USERNAME: "fame" | ||
MONGO_PASSWORD: "super-secret-password" | ||
|
||
secrets: | ||
ssh_priv_key: | ||
file: ./ssh/id_rsa | ||
|
||
volumes: | ||
fame-share: | ||
|
||
services: | ||
fame-mongo: | ||
image: fame-mongo | ||
environment: | ||
MONGO_INITDB_DATABASE: "fame" | ||
container_name: fame-mongo | ||
restart: unless-stopped | ||
volumes: | ||
- /opt/fame-mongo:/data/db:z | ||
command: --auth | ||
networks: | ||
- "fame_internal" | ||
|
||
fame-web: | ||
image: fame-web | ||
container_name: fame-web | ||
depends_on: | ||
- fame-mongo | ||
environment: | ||
<<: *mongo_env | ||
FAME_INSTALL_COMMUNITY_REPO: "1" | ||
FAME_URL: "http://localhost/" | ||
FAME_ADMIN_FULLNAME: "The Admin" | ||
FAME_ADMIN_EMAIL: "[email protected]" | ||
FAME_ADMIN_GROUPS: "cert" | ||
FAME_ADMIN_DEFAULT_SHARING: "cert" | ||
FAME_ADMIN_PERMISSIONS: "*" | ||
FAME_ADMIN_PASSWORD: "secret" | ||
FAME_PUBLIC_KEY: "ssh-rsa ..." | ||
FAME_SECRET_KEY: "<ssh secret key>" | ||
FAME_AUTHENTICATION_TYPE: "user_password" | ||
# LDAP_URI: "ldap://example.com" | ||
# LDAP_USER: "ldap-user" | ||
# LDAP_PASSWORD: "ldap-password" | ||
# LDAP_FILTER_EMAIL: "(&(objectCategory=Person)(sAMAccountName=*)(mail={})" | ||
# LDAP_FILTER_DN: "OU=People,DC=example,DC=com" | ||
volumes: | ||
- /opt/fame-modules:/fame/fame/modules:z | ||
- /opt/fame-storage:/fame/storage:z | ||
- /opt/fame-avatars:/fame/web/static/img/avatars:z | ||
labels: | ||
- "traefik.enable=true" | ||
- "traefik.docker.network=traefik_default" | ||
- "traefik.port=8080" | ||
- "traefik.frontend.rule=Host: fame.example.com" | ||
networks: | ||
- "fame_internal" | ||
- "traefik_default" | ||
restart: unless-stopped | ||
hostname: fame-web | ||
|
||
fame-worker: | ||
image: fame-worker | ||
container_name: fame-worker | ||
depends_on: | ||
- fame-mongo | ||
- fame-web | ||
environment: | ||
<<: *mongo_env | ||
FAME_URL: "http://fame-web:8080/" | ||
DOCKER_HOST: "unix:///var/run/docker.sock" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock:z | ||
- fame-share:/fame/docker-storage:z | ||
networks: | ||
- "fame_internal" | ||
- "gateway" | ||
secrets: | ||
- ssh_priv_key |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "[+] Ensuring empty __init__.py in modules directory" | ||
touch /fame/fame/modules/__init__.py | ||
|
||
echo "[+] Adjusting permissions" | ||
chown fame:fame /fame -R | ||
|
||
exec "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
TIMEOUT=60 | ||
|
||
echo "[+] Waiting $TIMEOUT seconds for MongoDB to come up" | ||
python docker/wait-for.py fame-mongo 27017 $TIMEOUT | ||
if [ "$?" -ne "0" ]; then | ||
echo "[X] Could not connect to MongoDB instance - is it up and running?" | ||
exit 1 | ||
fi | ||
|
||
utils/run.sh utils/install_docker.py | ||
|
||
chown fame:fame /fame -R | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this step be in the Dockerfile ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step should not be in the Dockerfile in my opinion, because there are several volumes that are mounted beneath /fame that may have the wrong permissions for FAME to access it. Thus, we do the |
||
|
||
echo "[+] Running webserver" | ||
exec /fame/env/bin/uwsgi -H /fame/env --uid fame --http :8080 -w webserver --callable app |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "[+] Ensuring presence of temp dir" | ||
mkdir -p temp && chown fame:fame temp/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two steps look like they should be in the Dockerfile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setting up git, yes. But I am not sure about the temp dir. Sure, we can create it in the Dockerfile but the chown is still necessary here. |
||
|
||
if [ -f /run/secrets/ssh_priv_key ]; then | ||
echo "[+] Copying SSH private key" | ||
mkdir -p conf | ||
cp /run/secrets/ssh_priv_key conf/id_rsa | ||
chown fame:fame conf -R | ||
chmod 600 conf/id_rsa | ||
fi | ||
|
||
if [ -e /var/run/docker.sock ]; then | ||
gid="$(stat -c %g /var/run/docker.sock)" | ||
echo "[+] Creating docker_fame group with gid $gid and adding user 'fame' to it" | ||
groupadd -g $gid docker_fame | ||
usermod -aG docker_fame fame | ||
fi | ||
|
||
TIMEOUT=60 | ||
|
||
echo "[+] Waiting $TIMEOUT seconds for MongoDB to come up" | ||
python docker/wait-for.py fame-mongo 27017 $TIMEOUT | ||
if [ "$?" -ne "0" ]; then | ||
echo "[X] Could not connect to MongoDB instance - is it up and running?" | ||
exit 1 | ||
fi | ||
|
||
echo "[+] Waiting $TIMEOUT seconds for web server to come up" | ||
python docker/wait-for.py fame-web 8080 $TIMEOUT | ||
if [ "$?" -ne "0" ]; then | ||
echo "[X] Could not connect to web server instance - is it up and running?" | ||
exit 1 | ||
fi | ||
|
||
exec utils/run.sh worker.py -r 5 -c '--uid fame --gid fame' |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM mongo | ||
|
||
COPY adduser.js /docker-entrypoint-initdb.d/adduser.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use fame"; | ||
db.createUser({ | ||
user: "fame", | ||
pwd: "super-secret-password", | ||
roles: [ | ||
{ role: "readWrite", db: "fame" }, | ||
{ role: "dbOwner", db: "fame" } | ||
] | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that you are using a dedicated MongoDB instance for FAME and that it is only available to the dedicated Docker network, do we really need to bother with this form of authentication ? I think it would probably be simpler to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, you are perfectly right. But the main drawback I saw in that (and therefore chose not to use it) is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are the username and password set ?