Closed marlluslustosa closed 4 years ago
May be. But I don’t think that dockerized mysql is effective
пт, 22 марта 2019 г. в 21:47, Marllus Lustosa notifications@github.com:
there is the possibility of a dockerized version of politepol?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/taroved/pol/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/AFASWlt5Oy2xxBFWoaR9ecdzGUuO7EoKks5vZSU0gaJpZM4cENMb .
I have seen a docker container of just mysql several times, and some pretty good use cases for it.
As far as how effective it would be that I cant say.
I talked to know if anyone has already done some dockerized politepol. :/ I'm out of time at the moment of this, but I'm interested in contributing a few bucks for someone to implement this and make docker-compose.yml or Dockerfile available. It would be something like:
1 container for app and webserver 1 container for mysql
Anyone interested in doing this?
Do you know docker is for dev not for production ? Docker is more or less a linux with cgroups and others tools policy.
A container can be used both for dev and for production. Today it is common for programmers to make the dockerized version of their projects available to facilitate deployment.
docker is used for production in many places.
Look at AWS's ECS as a big example.
They are great and lets companies scale up/down near instantaneously
@marlluslustosa I started to dockerize this project
@melihcolpan Have you created any public repositories to get help from other community members? Share with us!
@marlluslustosa If any other contributors join, we can write the codes more modular and usable. I will start on this week and share with you. Best wishes
I'm waiting!
If only the app would be dockerized, and let us handle mysql on our own (another container, standalone installation, etc), then it would be a huge step forward.
Not sure I fully understand what you mean.
The beauty of MySQL is you can install it anywhere and on almost anything, the app supports a MySQL as well as others.
If you were to also view the settings, you can see you have the ability to specify where that MySQL server is located be it on the same machine or on a different host
My problem is that the project is still not dockerized, and somebody here above told that mysql should not be dockerized in the project. I just humbly suggested that the app should be dockerized anyways, and we can decide on our own how we deploly mysql in our env. I'll surely put it in a docker compose file but others might have better idea. We should advance with the dockerization of the project itself, and put the mysql connection parameters to docker env variables.
Why not do it all yourself then?
Create a docker with the project in it, you can already use a docker mysql since settings lets you specify host, port, db, etc for mysql
Yes, I'm planning to do it if nobody above doesn't already have a working solution. Did anyone get somewhere so far with it? :)
I could do it, but currently I have no time for that and with many projects in hand... Maybe one hour i do that. I think if anyone wanted a functional container it would just install the application in a docker and export it to .tar. It would be simple to do and would work.
FYI, I had some time to play with Docker this afternoon, here is how far I got if somebody wants to follow-up.
I wanted to go on a multistage build path as there are many dev dependencies that are not needed in production, so the behemoth builder stage can be discarded later for a more lightweight container (e.g., Alpine-based nginx
).
Also figured out that I should use env variables with an entrypoint.sh
to replace Django settings on run-time instead of build time.
I think it would make things a lot easier if the project had releases available here: https://github.com/taroved/pol/releases as I could just download the latest .tar.gz
file that has everything already built, unpack it, and run it in a prod container right away.
There are also several pip
warnings and errors that the project uses Python 2 and ERROR: parsel 1.5.2 has requirement w3lib>=1.19.0, but you'll have w3lib 1.17.0 which is incompatible.
but you might already know these.
If you put these files to the project root, and run the below commands, you'll get an interactive shell where you can look around inside the container but nothing is already built, just the deps got installed.
.dockerignore
.dockerignore
Dockerfile
docker-compose.yml
Dockerfile
FROM ubuntu:bionic as builder
RUN echo 'APT::Install-Recommends 0;' >> /etc/apt/apt.conf.d/01norecommends \
&& echo 'APT::Install-Suggests 0;' >> /etc/apt/apt.conf.d/01norecommends \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y bash vim.tiny wget sudo net-tools ca-certificates unzip apt-transport-https \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal libmysqlclient-dev libxml2-dev libxslt-dev python-dev libffi-dev gcc libssl-dev gettext \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python-pip python-setuptools nodejs node-gyp npm ruby nginx \
&& pip install --upgrade pip \
&& npm install -g less@2.7.1 \
&& npm install -g yuglify@0.1.4 \
&& gem install sass -v 3.4.22
ARG DB_NAME=pol
ARG DB_USER=root
ARG DB_PASSWORD=toor
ARG DB_HOST=127.0.0.1
ARG DB_PORT=3306
ARG TIME_ZONE=UTC
EXPOSE 80
WORKDIR /app
ADD . .
RUN pip install -r requirements.txt
RUN cp ./nginx/default.site-example /etc/nginx/sites-available/default \
&& cp ./frontend/frontend/settings.py.example ./frontend/frontend/settings.py \
&& SECRET_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&*()_+?><~' | fold -w 32 | head -n 1) \
&& sed -i -E -e "s/(SECRET_KEY = ').*/\1${SECRET_KEY}'/" \
-e "s/(DEBUG = ).*/\1False/" \
-e "s/('NAME': ')pol(',)/\1${DB_NAME}\2/" \
-e "s/('USER': ')root(',)/\1${DB_USER}\2/" \
-e "s/('PASSWORD': ')toor(',)/\1${DB_PASSWORD}\2/" \
-e "s/('HOST': ')127\.0\.0\.1(',)/\1${DB_HOST}\2/" \
-e "s/('PORT': ')3306(',)/\1${DB_PORT}\2/" \
-e "s/(TIME_ZONE = ').*/\1${TIME_ZONE}'/" \
./frontend/frontend/settings.py \
&& service nginx reload
# RUN pushd ./frontend \
# && python manage.py migrate \
# && python manage.py loaddata fields.json \
# && popd
# RUN pushd . \
# && python downloader.py \
# && popd
# RUN pushd ./frontend \
# && python manage.py runserver \
# && popd
CMD ["/bin/bash", "-c", "echo hello; sleep 500000"]
# multistage build
# FROM .... as prod
# COPY built project from builder
docker-compose.yml
version: "3"
services:
politepol:
build:
context: .
args:
- DB_NAME=politepol
- DB_USER=rooooooooooot
- DB_PASSWORD=toooooooooooor
- DB_HOST=192.168.1.1
- DB_PORT=3306
- TIME_ZONE=Europe\/Budapest
image: politepol:latest
container_name: politepol
restart: unless-stopped
ports:
- "8080:80"
# environment:
Usage
docker-compose up -d --build
docker ps -a
docker-compose exec politepol bash
# look around then exit
docker-compose down
@immanuelfodor , I took your code as a base and built another container with the mysql database, i created a bridge for them to communicate, changed some things using sed referring to the issues that are occurring (https://github.com/taroved/pol/issues/30), and redid the network redirects.
I have tested and it is working fine. I forked the project and put the files there (https://github.com/marlluslustosa/pol). Just an addendum: One thing that still doesn't work is the xpath check part (in the manual entry part of the title/description). I think this is error in the main code. I haven't had time to check the logs yet.
@taroved , if you want I can send a 'Pull Request' to your main project. What do you think?
Thanks!
@marlluslustosa yes, create pull request
I've only read your comment so far, it should be awesome, you're a hero :)
I could not find the pull request, so I opened it for you, looks great! If I have some time today, I'll give it a try to test it.
Well done, added some comments to #32
there is the possibility of a dockerized version of politepol?