se agrega archivos docker para servidor de desarrollo

francisco/prueba1
Francisco Sandoval 2023-06-06 14:36:40 +00:00
parent a8ed87b6a3
commit b48d18c450
4 changed files with 66 additions and 8 deletions

View File

@ -0,0 +1,39 @@
#
# Este archivo es para crear imagen en servidor de desarrollo
# se le instala servicio ssh y git
#
FROM python:alpine3.18
RUN apk add --update --no-cache \
openssh-server \
openssh-sftp-server \
openssh-client \
curl git bash nano
ARG ROOTPASS=mypassword
RUN mkdir /var/run/sshd
RUN echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config && \
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && \
echo 'AllowTcpForwarding yes' >> /etc/ssh/sshd_config && \
echo -n "root:$ROOTPASS" | chpasswd
# CREATE COMMAND START
RUN echo "#!/bin/sh" > /start.sh && \
echo "ssh-keygen -A" >> /start.sh && \
echo 'exec /usr/sbin/sshd -D -e "$@"' >> /start.sh && \
chmod +x -v /start.sh
# CUSTOM PROMPT
RUN touch /root/.profile && \
echo "alias ll='ls -alF --color=auto'" >> /root/.profile && \
echo "alias la='ls -A --color=auto'" >> /root/.profile && \
echo "alias l='ls -CF --color=auto'" >> /root/.profile && \
echo ". ~/.prompt" >> /root/.profile && \
echo 'export PS1="\r\n\e[30;46m \A \e[37;44m\[ \u\] \e[30;42m\[ \w \]\e[m\r\n\$ "' > /root/.prompt
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
CMD ["/start.sh"]
EXPOSE 22 8000

View File

@ -1,8 +1,8 @@
#!/bin/sh
cd /app
cd /root/app
# si no existe directorio de ambiente, se crea
if [ ! -d /app/libs ]; then
if [ ! -d ./libs ]; then
python -m venv libs
. ./libs/bin/activate
pip install -r requirements.txt
@ -11,9 +11,27 @@ fi
# activar ambiente con dependencias
. ./libs/bin/activate
if [ ! -d /app/project ]; then
if [ ! -d ./project ]; then
django-admin startproject project
fi
# iniciar servidor con puerto 8000
python /app/project/manage.py runserver 0.0.0.0:8000
if [ ! -f .env ]; then
cp .env.develop .env
fi
# asignar nueva password a root
if [ "$ROOTPASS" != "" ]; then
echo "Cambiando la password de root..."
echo -n "root:$ROOTPASS" | chpasswd
unset ROOTPASS
fi
# indicar a git carpeta segura
git config --global --add safe.directory /root/app
# iniciar ssh
sh /start.sh &
# iniciar servidor
python /root/app/project/manage.py runserver 0.0.0.0:$PORT

View File

@ -26,7 +26,7 @@ SECRET_KEY = 'django-insecure-xhlm+3=u!2hg7cj@jmhpa!v^gq-3n))+(243_p&r45(*e)ynxf
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = [ '*' ]
# Application definition
@ -136,4 +136,4 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
}

View File

@ -41,4 +41,5 @@ python /app/project/manage.py runserver 0.0.0.0:8000
~~~bash
python manage.py inspectdb > api/models.py
~~~
~~~