Archived
Change docker setup to allow testing of multiple student orgs #2
@@ -1,11 +0,0 @@
|
||||
# Dockerfile (apache-static)
|
||||
FROM httpd:2.4
|
||||
|
||||
LABEL maintainer="random@gmail.com"
|
||||
|
||||
# Copy static site into the default Apache document root
|
||||
COPY ./static-site/ /usr/local/apache2/htdocs/
|
||||
|
||||
EXPOSE 80
|
||||
# httpd base image already starts apache with the correct CMD
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
This repository provides a Dockerized environment for running WordPress locally using Docker Compose. It's designed for quick development and testing without complex installations.
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Apache Server**: Single Apache container with `mod_userdir` enabled
|
||||
- **User Data**: Shared volume containing student org home directories
|
||||
- **WordPress**: Separate WordPress + MariaDB containers for testing
|
||||
- **Structure**: Each org has `/home/<orgname>/public_html/` served at `http://localhost:8080/~<orgname>`
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
1. **Clone the repository:**
|
||||
@@ -9,28 +16,47 @@ This repository provides a Dockerized environment for running WordPress locally
|
||||
```bash
|
||||
git clone https://git.1337.berkeley.edu/Committee/Secure-OCF-Web-Hosting.git
|
||||
cd Secure-OCF-Web-Hosting/WordPress-Docker
|
||||
````
|
||||
```
|
||||
|
||||
2. **Build and start the containers:**
|
||||
2. **Install Docker Desktop:**
|
||||
- [macOS](https://docs.docker.com/desktop/setup/install/mac-install/)
|
||||
- [Windows](https://docs.docker.com/desktop/setup/install/windows-install/)
|
||||
|
||||
3. **Build and start the containers:**
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Access WordPress:**
|
||||
4. **Access WordPress:**
|
||||
|
||||
Open your browser and navigate to:
|
||||
|
||||
```
|
||||
http://localhost:8080
|
||||
http://localhost:8081
|
||||
```
|
||||
|
||||
Follow the on-screen instructions to complete the WordPress setup.
|
||||
|
||||
## 🛠️ Project Structure
|
||||
### Access sites:
|
||||
- **Student org sites**:
|
||||
- http://localhost:8080/~studentorg1
|
||||
- http://localhost:8080/~studentorg2
|
||||
- http://localhost:8080/~studentorg3
|
||||
- **WordPress**: http://localhost:8081
|
||||
|
||||
* `docker-compose.yml`: Defines the services, networks, and volumes for the WordPress and MySQL containers.
|
||||
* `Dockerfile`: Customizes the WordPress image (if applicable).
|
||||
### Add new student org:
|
||||
```bash
|
||||
docker exec -it ocf_apache_server bash
|
||||
mkdir -p /home/neworg/public_html
|
||||
echo "<h1>New Org</h1>" > /home/neworg/public_html/index.html
|
||||
chown -R www-data:www-data /home/neworg
|
||||
```
|
||||
|
||||
### View Apache logs:
|
||||
```bash
|
||||
docker logs ocf_apache_server
|
||||
```
|
||||
|
||||
## ⚙️ Managing Containers
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Dockerfile (apache-static)
|
||||
FROM httpd:2.4
|
||||
|
||||
LABEL maintainer="random@gmail.com"
|
||||
|
||||
# Enable required Apache modules for user directories and PHP
|
||||
RUN sed -i \
|
||||
-e 's/#LoadModule userdir_module/LoadModule userdir_module/' \
|
||||
-e 's/#LoadModule vhost_alias_module/LoadModule vhost_alias_module/' \
|
||||
-e 's/#LoadModule rewrite_module/LoadModule rewrite_module/' \
|
||||
-e 's/#Include conf\/extra\/httpd-userdir.conf/Include conf\/extra\/httpd-userdir.conf/' \
|
||||
/usr/local/apache2/conf/httpd.conf
|
||||
|
||||
# Add custom configuration for user directories
|
||||
COPY httpd-userdir.conf /usr/local/apache2/conf/extra/httpd-userdir.conf
|
||||
|
||||
# Create example student org directories with basic content
|
||||
RUN mkdir -p /home/studentorg1/public_html && \
|
||||
echo "<h1>Welcome to Student Org 1's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg1/public_html/index.html && \
|
||||
mkdir -p /home/studentorg2/public_html && \
|
||||
echo "<h1>Welcome to Student Org 2's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg2/public_html/index.html && \
|
||||
mkdir -p /home/studentorg3/public_html && \
|
||||
echo "<h1>Welcome to Student Org 3's OCF Page</h1><p>This is a test page.</p>" > /home/studentorg3/public_html/index.html
|
||||
|
||||
# Set proper ownership
|
||||
RUN chown -R www-data:www-data /home
|
||||
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,20 @@
|
||||
# Settings for user home directories
|
||||
#
|
||||
# Required module: mod_userdir
|
||||
|
||||
UserDir /home/*/public_html
|
||||
|
||||
#
|
||||
# Control access to UserDir directories.
|
||||
# Mimics OCF structure where user directories are in /home
|
||||
#
|
||||
<Directory "/home/*/public_html">
|
||||
AllowOverride All
|
||||
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
|
||||
Require all granted
|
||||
|
||||
# Allow .htaccess usage for student customization
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
</IfModule>
|
||||
</Directory>
|
||||
@@ -1,17 +1,28 @@
|
||||
version: "3.8"
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
apache-static:
|
||||
apache:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: apache-static
|
||||
context: ./apache
|
||||
ports:
|
||||
- "8080:80" # static landing page -> http://localhost:8080
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- userdata:/home
|
||||
depends_on:
|
||||
- userdata
|
||||
container_name: apache-static
|
||||
restart: unless-stopped
|
||||
|
||||
userdata:
|
||||
image: busybox
|
||||
volumes:
|
||||
- userdata:/home
|
||||
container_name: user_data
|
||||
command: /bin/true
|
||||
|
||||
db:
|
||||
image: mariadb:11
|
||||
container_name: wp-db
|
||||
container_name: wp_db
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: rootpass
|
||||
MYSQL_DATABASE: wp_db
|
||||
@@ -23,7 +34,7 @@ services:
|
||||
|
||||
wordpress:
|
||||
image: wordpress:latest
|
||||
container_name: wp-site
|
||||
container_name: wp_site
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
@@ -32,11 +43,12 @@ services:
|
||||
WORDPRESS_DB_PASSWORD: wp_pass
|
||||
WORDPRESS_DB_NAME: wp_db
|
||||
ports:
|
||||
- "8081:80" # WordPress site -> http://localhost:8081
|
||||
- "8081:80" # WordPress site -> http://localhost:8081
|
||||
volumes:
|
||||
- wp_data:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
userdata:
|
||||
db_data:
|
||||
wp_data:
|
||||
|
||||
Reference in New Issue
Block a user