Hey everyone, I’m trying to deploy Frappe LMS on my Azure AKS cluster using Docker with a Postgres database. However, when the bench install
command runs in the Dockerfile, it throws an error:
Error in query: relation "tabSingles" does not exist
LINE 1: SELECT "value" FROM "tabSingles" WHERE "doctype" = 'System Set...
here is my dockerfile as well if someone can help
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
libffi-dev \
libssl-dev \
gnupg \
cron \
python3-dev \
wget \
pkg-config \
postgresql-client \
redis-server \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js and Yarnx
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g yarn
# Create a non-root user
RUN useradd -m -s /bin/bash frappe
RUN mkdir -p /home/frappe
RUN chown -R frappe:frappe /home/frappe
# Set working directory
WORKDIR /home/frappe
# Create and activate virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install Python dependencies
RUN pip install --upgrade pip wheel setuptools
RUN pip install frappe-bench psycopg2-binary
# Switch to non-root user
USER frappe
# Clean up any existing bench directory and initialize fresh
RUN rm -rf frappe-bench && \
bench init frappe-bench \
--skip-redis-config-generation \
--skip-assets \
--no-backups \
--python "$(which python)" \
--frappe-branch version-15 \
--frappe-path https://github.com/frappe/frappe.git
WORKDIR /home/frappe/frappe-bench
# Install LMS app
RUN bench get-app --branch develop "https://your_github_token@github.com/your_repo.git"
# Create startup script
RUN echo '#!/bin/bash\n\
\n\
# Set database details\n\
export DB_HOST="your-db-server.postgres.database.azure.com"\n\
export DB_USER="your_db_user"\n\
export DB_PASSWORD="your_db_password"\n\
export DB_NAME="your_db_name"\n\
export DB_PORT="5432"\n\
\n\
# Set Redis details\n\
export REDIS_HOST="your-redis-instance.redis.cache.windows.net"\n\
export REDIS_PORT="6380"\n\
\n\
# Test database connection\n\
echo "Testing database connection..."\n\
PGPASSWORD=${DB_PASSWORD} psql -h ${DB_HOST} -U ${DB_USER} -d ${DB_NAME} -p ${DB_PORT} -c "SELECT 1;"\n\
\n\
# Create sites directory if it doesnt exist\n\
mkdir -p sites\n\
mkdir -p "sites/${SITE_NAME:-lms.local}"\n\
\n\
# Create common site config\n\
cat <<EOF > sites/common_site_config.json\n\
{\n\
"db_host": "${DB_HOST}",\n\
"db_port": ${DB_PORT},\n\
"db_name": "${DB_NAME}",\n\
"db_password": "${DB_PASSWORD}",\n\
"redis_cache": "rediss://${REDIS_HOST}:${REDIS_PORT}",\n\
"redis_queue": "rediss://${REDIS_HOST}:${REDIS_PORT}",\n\
"redis_socketio": "rediss://${REDIS_HOST}:${REDIS_PORT}"\n\
}\n\
EOF\n\
\n\
# Create new site if it doesnt exist\n\
if [ ! -f "sites/${SITE_NAME:-lms.local}/site_config.json" ]; then\n\
bench new-site ${SITE_NAME:-lms.local} --db-name ${DB_NAME} --db-password ${DB_PASSWORD} --admin-password admin\n\
bench --site ${SITE_NAME:-lms.local} install-app lms\n\
bench --site ${SITE_NAME:-lms.local} migrate\n\
bench --site ${SITE_NAME:-lms.local} clear-cache\n\
bench --site ${SITE_NAME:-lms.local} clear-website-cache\n\
fi\n\
\n\
# Start the development server\n\
exec bench start' > /home/frappe/start.sh
EXPOSE 8000 9000 6379
CMD ["/home/frappe/start.sh"]