Server migration
This commit is contained in:
parent
3c7f5047f2
commit
f8735354a2
2 changed files with 90 additions and 0 deletions
67
Dockerfile
Normal file
67
Dockerfile
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Use Alpine Linux as base
|
||||
FROM git.esculta.es/aesculta/alpine-base
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk update && apk add --no-cache \
|
||||
python3 \
|
||||
python3-dev \
|
||||
postgresql-dev \
|
||||
gcc \
|
||||
musl-dev \
|
||||
libffi-dev \
|
||||
jpeg-dev \
|
||||
zlib-dev \
|
||||
git \
|
||||
bash \
|
||||
su-exec \
|
||||
xmlsec-dev \
|
||||
xmlsec \
|
||||
py3-xmlsec \
|
||||
openldap-dev\
|
||||
py3-ldap
|
||||
|
||||
# Create and activate Python virtual environment
|
||||
RUN python3 -m venv /venv
|
||||
ENV PATH="/venv/bin:$PATH"
|
||||
|
||||
# Clone Tandoor Recipes repository (checking out stable version)
|
||||
RUN git clone --depth 1 --branch 1.5.33 https://github.com/TandoorRecipes/recipes.git /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN echo -n 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so
|
||||
|
||||
# Install Python dependencies in virtual environment
|
||||
RUN /venv/bin/pip install --no-cache-dir --upgrade pip && \
|
||||
/venv/bin/pip install --no-cache-dir python-ldap xmlsec
|
||||
|
||||
# Create user and set permissions
|
||||
RUN adduser -D -u 1000 tandoor && \
|
||||
chown -R tandoor:tandoor /app /venv
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Environment variables (override these in your deployment)
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
DB_ENGINE=django.db.backends.postgresql \
|
||||
DB_HOST=postgres \
|
||||
DB_PORT=5432 \
|
||||
DB_NAME=tandoor \
|
||||
DB_USER=tandoor \
|
||||
DB_PASSWORD=changeme \
|
||||
SECRET_KEY=changeme \
|
||||
DEBUG=0 \
|
||||
STATIC_ROOT=/app/static \
|
||||
MEDIA_ROOT=/app/media
|
||||
|
||||
# Expose port
|
||||
EXPOSE 80
|
||||
|
||||
# Volumes for persistent data
|
||||
VOLUME ["/app/media", "/app/static"]
|
||||
|
||||
# Entrypoint and command
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:80", "--user", "tandoor", "--group", "tandoor", "recipes.wsgi"]
|
||||
23
entrypoint.sh
Normal file
23
entrypoint.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check for required environment variables
|
||||
if [ -z "$DB_HOST" ] || [ -z "$DB_PORT" ] || [ -z "$SECRET_KEY" ]; then
|
||||
echo "Error: Required environment variables not set!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for PostgreSQL to be available
|
||||
echo "Waiting for PostgreSQL..."
|
||||
while ! nc -z $DB_HOST $DB_PORT; do
|
||||
sleep 0.1
|
||||
done
|
||||
echo "PostgreSQL started"
|
||||
|
||||
# Run database migrations using virtual environment
|
||||
su-exec tandoor /venv/bin/python manage.py migrate
|
||||
|
||||
# Collect static files
|
||||
su-exec tandoor /venv/bin/python manage.py collectstatic --noinput
|
||||
|
||||
# Start application
|
||||
exec "$@"
|
||||
Loading…
Add table
Reference in a new issue