Complete step‐by‐step guide to install Lucee and PostgreSQL on Google Cloud Platform using Docker
solution:
Below is a complete step‐by‐step guide to install Lucee and PostgreSQL on Google Cloud Platform using Docker:
──────────────────────────────
Step 1: Create a GCP Project
• Go to https://console.cloud.google.com/ and log in.
• Create a new project.
• Enable billing and ensure the Compute Engine API is enabled.
──────────────────────────────
Step 2: Create a Compute Engine VM
• In the GCP Console, navigate to Compute Engine > VM instances.
• Click “Create Instance.”
• Choose a Linux OS (Ubuntu is recommended).
• Select a machine type that fits your needs.
• Click “Create.”
──────────────────────────────
Step 3: Connect to Your VM
• On the VM list, click “SSH” next to your newly created instance to open a browser-based terminal.
──────────────────────────────
Step 4: Install Docker and Docker Compose
1. Update packages:
sudo apt-get update
2. Install Docker:
sudo apt-get install docker.io -y
3. Start and enable Docker:
sudo systemctl start docker
sudo systemctl enable docker
4. Install Docker Compose:
sudo apt-get install docker-compose -y
(If not available, you can install it using curl following Docker’s official instructions.)
──────────────────────────────
Step 5: Set Up Your Application Directory
• Create a directory and move into it:
mkdir lucee-postgres && cd lucee-postgres
──────────────────────────────
Step 6: Create the docker-compose.yml File
• In the lucee-postgres directory, create a file named docker-compose.yml:
nano docker-compose.yml
• Paste the following content (adjust POSTGRES_PASSWORD as desired):
------------------------------------------------
version: '3'
services:
lucee:
image: lucee/lucee:latest
ports:
- "8888:8888"
depends_on:
- db
db:
image: postgres:latest
environment:
POSTGRES_PASSWORD: yourpassword
ports:
- "5432:5432"
------------------------------------------------
• Save and exit (in nano, press Ctrl+O, Enter, then Ctrl+X).
──────────────────────────────
Step 7: Start the Containers
• In your application directory, run:
docker-compose up -d
• Use docker ps to confirm both containers are running.
──────────────────────────────
Step 8: Configure Firewall Rules on GCP
• In the GCP Console, go to VPC network > Firewall rules.
• Create a rule to allow inbound TCP traffic on port 8888 (for Lucee).
• (Optionally, create a rule for port 5432 if you need external PostgreSQL access; otherwise keep it private.)
──────────────────────────────
Step 9: Test the Lucee Welcome Page
• Open your browser and navigate to:
http://[YOUR_VM_EXTERNAL_IP]:8888
• You should now see the Lucee welcome page.
──────────────────────────────
Step 10: Set the Lucee Admin Password Securely
For security, Lucee requires that you import a password file before the initial admin login.
1. Open a shell in the Lucee container:
docker exec -it lucee-postgres_lucee_1 bash
2. Locate the Lucee server context directory:
find / -type d -name context 2>/dev/null
(You’ll likely see two results. The correct path is typically the nested “context” folder, for example:)
/opt/lucee/server/lucee-server/context/context
3. Change to that directory:
cd /opt/lucee/server/lucee-server/context/context
4. Since text editors like nano may not be available, create the password file with echo:
echo "YourNewSecurePassword" > password.txt
echo "admin" > password.txt
(Replace YourNewSecurePassword with the desired password.)
5. Verify the file was created:
cat password.txt
6. Exit the container shell:
exit
7. Open your browser and navigate to:
http://[YOUR_VM_EXTERNAL_IP]:8888/lucee/admin/server.cfm
8. Click the “Import File” button.
Lucee will read the password from password.txt, set the admin password, and then delete the file.
9. You can now log in to the Lucee Admin with username “admin” and your new password.
──────────────────────────────
Step 11: Next Steps
• Configure Lucee for your application needs.
• For production, consider setting up persistent volumes for data and using Cloud SQL for PostgreSQL if you prefer managed services.
• Secure your instance further by limiting external access to sensitive ports.
──────────────────────────────
answer:
You now have a complete setup with Lucee and PostgreSQL running on a GCP Compute Engine VM using Docker Compose. Follow the steps above to deploy, test, and securely configure Lucee’s admin password. Enjoy building your application!
Comments
Post a Comment