se agrega archivos docker para servidor de desarrollo
parent
a8ed87b6a3
commit
b48d18c450
|
@ -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
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd /app
|
cd /root/app
|
||||||
|
|
||||||
# si no existe directorio de ambiente, se crea
|
# si no existe directorio de ambiente, se crea
|
||||||
if [ ! -d /app/libs ]; then
|
if [ ! -d ./libs ]; then
|
||||||
python -m venv libs
|
python -m venv libs
|
||||||
. ./libs/bin/activate
|
. ./libs/bin/activate
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
@ -11,9 +11,27 @@ fi
|
||||||
# activar ambiente con dependencias
|
# activar ambiente con dependencias
|
||||||
. ./libs/bin/activate
|
. ./libs/bin/activate
|
||||||
|
|
||||||
if [ ! -d /app/project ]; then
|
if [ ! -d ./project ]; then
|
||||||
django-admin startproject project
|
django-admin startproject project
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# iniciar servidor con puerto 8000
|
if [ ! -f .env ]; then
|
||||||
python /app/project/manage.py runserver 0.0.0.0:8000
|
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
|
||||||
|
|
||||||
|
|
|
@ -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!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = [ '*' ]
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
@ -136,4 +136,4 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
|
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue