21. classVRroom. Dockerització del projecte Django. - Grupo 6
La revisió el 17:16, 29 març 2022 per [email protected] (discussió | contribucions)
Dockerfile
# We Use an official Python runtime as a parent image FROM python:3.8-slim # install db libs RUN apt-get update RUN apt-get install -y default-mysql-client libmariadb-dev RUN apt-get install -y libmariadb-dev-compat gcc gdal-bin libjpeg-dev RUN apt-get install -y gcc python3-dev python3-mysqldb RUN apt-get install -y libpq-dev python-dev python3-venv # install app libs COPY requirements.txt requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt # Mounts the application code to the image COPY . code # establish workdir WORKDIR /code EXPOSE 8000 # runs the development server ENTRYPOINT ["python3", "manage.py"] CMD ["creategroups.py"] CMD ["runserver","0.0.0.0:8000"]
Docker-compose.yml
GNU nano 4.8 docker-compose.yml version: '3.1' services: django_app: build: . restart: always ports: - 8000:8000 environment: - DATABASE_URL=sqlite:///db.sqlite3 - DEBUG=False - SECRET_KEY=asecretkeyblabla volumes: - ./db.sqlite3:/code/db.sqlite3
Para añadir grupos y usuarios:
azureuser@VMRoom:~/ClassVRoom/classroomvr/management/commands$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2edf4184d570 classvroom_django_app "python3 manage.py r…" 11 minutes ago Up 11 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp classvroom_django_app_1
azureuser@VMRoom:~/ClassVRoom/classroomvr/management/commands$ sudo docker exec -ti 2ed bash
root@2edf4184d570:/code# ./manage.py creategroups