user27844577
user27844577

Reputation: 11

Dockerizing PHP (Smarty) and SQLite3 Project

I’m trying to Dockerize my PHP (Smarty) and SQLite3 website but am encountering issues with my Dockerfile and Docker Compose configuration. Currently, I could display both html and css with localhost:8000, but all parts that I wrote with PHP is displayed as plain text, which seems my dockerfile does not install the Smarty (and DB).

Here's a summary of my Dockerfile setup (I've trimmed it down to the essential parts):

dockerfile

Copy code
FROM php:8.2.0-apache

# Install dependencies
RUN apt-get update && apt-get install -y libzip-dev unzip curl sqlite3 libsqlite3-dev
RUN docker-php-ext-install zip pdo pdo_sqlite

# Set working directory
WORKDIR /var/www/html/

# Copy project files
COPY ./templates ./templates
# ... other COPY commands

# Set permissions
RUN chown -R www-data:www-data /var/www/html

# Enable Apache mod_rewrite
RUN a2enmod rewrite

CMD ["apache2-foreground"]

And here’s my compose.yaml file:

services:
  web:
    build: .
    container_name: corporate_site_web
    ports:
      - "8000:80"
    networks:
      - corporate_site_network

networks:
  corporate_site_network:
    driver: bridge

volumes:
  db-compose-volume:

I would appreciate any guidance on fixing my setup as I'm new to Docker and struggling to get it to work. Thank you!

Upvotes: 1

Views: 49

Answers (0)

Related Questions