Skip to content

Commit cf04b1a

Browse files
committed
compose sample and assignment file added
1 parent d947b2f commit cf04b1a

File tree

104 files changed

+47041
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+47041
-0
lines changed

compose-assignment-1/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Assignment: Writing a Compose File
2+
3+
> Goal: Create a compose config for a local Drupal CMS website
4+
5+
- This empty directory is where you should create a docker-compose.yml
6+
- Use the `drupal:8.8.2` image along with the `postgres:12.1` image
7+
- Set the version to 2
8+
- Use `ports` to expose Drupal on 8080
9+
- Be sure to setup POSTGRES_PASSWORD on postgres image
10+
- Walk through Drupal config in browser at http://localhost:8080
11+
- Tip: Drupal assumes DB is localhost, but it will actually be on the compose service name you give it
12+
- Use Docker Hub documentation to figure out the right environment and volume settings
13+
- Extra Credit: Use volumes to store Drupal unique data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '2'
2+
3+
services:
4+
drupal:
5+
image: drupal:8.8.2
6+
ports:
7+
- "8080:80"
8+
volumes:
9+
- drupal-modules:/var/www/html/modules
10+
- drupal-profiles:/var/www/html/profiles
11+
- drupal-sites:/var/www/html/sites
12+
- drupal-themes:/var/www/html/themes
13+
postgres:
14+
image: postgres:12.1
15+
environment:
16+
- POSTGRES_PASSWORD=mypasswd
17+
18+
volumes:
19+
drupal-modules:
20+
drupal-profiles:
21+
drupal-sites:
22+
drupal-themes:

compose-assignment-2/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# create your custom drupal image here, based of official drupal

compose-assignment-2/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Assignment: Compose For On-The-Fly Image Building and Multi-Container Testing
2+
3+
Goal: This time imagine you're just wanting to learn Drupal's admin and GUI, or maybe you're a software tester and you need to test a new theme for Drupal. When configured properly, this will let you build a custom image and start everything with `docker-compose up` including storing important db and config data in volumes so the site will remember your changes across Compose restarts.
4+
5+
- Use the compose file you created in the last assignment (drupal and postgres) as a starting point.
6+
- Let's pin image version from Docker Hub this time. It's always a good idea to do that so a new major version doesn't surprise you.
7+
8+
## Dockerfile
9+
- First you need to build a custom Dockerfile in this directory, `FROM drupal:8.8.2` NOTE: if it fails to build, try the latest 8 branch version with `FROM drupal:8`
10+
- Then RUN apt package manager command to install git: `apt-get update && apt-get install -y git`
11+
- Remember to cleanup after your apt install with `rm -rf /var/lib/apt/lists/*` and use `\` and `&&` properly. You can find examples of them in drupal official image. More on this below under Compose file.
12+
- Then change `WORKDIR /var/www/html/themes`
13+
- Then use git to clone the theme with: `RUN git clone --branch 8.x-3.x --single-branch --depth 1 https://git.drupalcode.org/project/bootstrap.git`
14+
- Combine that line with this line, as we need to change permissions on files and don't want to use another image layer to do that (it creates size bloat). This drupal container runs as www-data user but the build actually runs as root, so often we have to do things like `chown` to change file owners to the proper user: `chown -R www-data:www-data bootstrap`. Remember the first line needs a `\` at end to signify the next line is included in the command, and at start of next line you should have `&&` to signify "if first command succeeds then also run this command"
15+
- Then, just to be safe, change the working directory back to its default (from drupal image) at `/var/www/html`
16+
17+
## Compose File
18+
- We're going to build a custom image in this compose file for drupal service. Use Compose file from previous assignment for Drupal to start with, and we'll add to it, as well as change image name.
19+
- Rename image to `custom-drupal` as we want to make a new image based on the official `drupal:8.8.2`.
20+
- We want to build the default Dockerfile in this directory by adding `build: .` to the `drupal` service. When we add a build + image value to a compose service, it knows to use the image name to write to in our image cache, rather then pull from Docker Hub.
21+
- For the `postgres:12.1` service, you need the same password as in previous assignment, but also add a volume for `drupal-data:/var/lib/postgresql/data` so the database will persist across Compose restarts.
22+
23+
## Start Containers, Configure Drupal
24+
- Start containers like before, configure Drupal web install like before.
25+
- After website comes up, click on `Appearance` in top bar, and notice a new theme called `Bootstrap` is there. That's the one we added with our custom Dockerfile.
26+
- Click `Install and set as default`. Then click `Back to site` (in top left) and the website interface should look different. You've successfully installed and activated a new theme in your own custom image without installing anything on your host other than Docker!
27+
- If you exit (ctrl-c) and then `docker-compose down` it will delete containers, but not the volumes, so on next `docker-compose up` everything will be as it was.
28+
- To totally clean up volumes, add `-v` to `down` command.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM drupal:8.8.2
2+
3+
4+
RUN apt-get update && apt-get install -y git \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
WORKDIR /var/www/html/themes
8+
9+
RUN git clone --branch 8.x-3.x --single-branch --depth 1 https://git.drupalcode.org/project/bootstrap.git \
10+
&& chown -R www-data:www-data bootstrap
11+
12+
WORKDIR /var/www/html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '2'
2+
# NOTE: move this answer file up a directory so it'll work
3+
4+
services:
5+
6+
drupal:
7+
image: custom-drupal
8+
build: .
9+
ports:
10+
- "8080:80"
11+
volumes:
12+
- drupal-modules:/var/www/html/modules
13+
- drupal-profiles:/var/www/html/profiles
14+
- drupal-sites:/var/www/html/sites
15+
- drupal-themes:/var/www/html/themes
16+
17+
postgres:
18+
image: postgres:12.1
19+
environment:
20+
- POSTGRES_PASSWORD=mypasswd
21+
volumes:
22+
- drupal-data:/var/lib/postgresql/data
23+
24+
volumes:
25+
drupal-data:
26+
drupal-modules:
27+
drupal-profiles:
28+
drupal-sites:
29+
drupal-themes:
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# create your drupal and postgres config here, based off the last assignment

compose-sample-3/docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '2'
2+
3+
# based off compose-sample-2, only we build nginx.conf into image
4+
# uses sample HTML static site from https://startbootstrap.com/themes/agency/
5+
6+
services:
7+
proxy:
8+
build:
9+
context: .
10+
dockerfile: nginx.Dockerfile
11+
ports:
12+
- '80:80'
13+
web:
14+
image: httpd
15+
volumes:
16+
- ./html:/usr/local/apache2/htdocs/

compose-sample-3/html/LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2013-2017 Blackrock Digital LLC.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

compose-sample-3/html/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# [Start Bootstrap](http://startbootstrap.com/) - [Agency](http://startbootstrap.com/template-overviews/agency/)
2+
3+
[Agency](http://startbootstrap.com/template-overviews/agency/) is a one page agency portfolio theme for [Bootstrap](http://getbootstrap.com/) created by [Start Bootstrap](http://startbootstrap.com/). This theme features several content sections, a responsive portfolio grid with hover effects, full page portfolio item modals, a responsive timeline, and a working PHP contact form.
4+
5+
## Getting Started
6+
7+
Several options are available to get started quickly:
8+
* [Download the latest release on Start Bootstrap](http://startbootstrap.com/template-overviews/agency/)
9+
* Clone the repo: `git clone https://github.com/BlackrockDigital/startbootstrap-agency.git`
10+
* Fork the repo
11+
12+
## Developing Using Source Files
13+
14+
To use the source files, you will need to have npm installed globally along with Gulp.js. To start:
15+
* Run `npm install` in the root directory
16+
* Run `gulp dev` and edit the files as needed
17+
18+
If you need to update the plugins included with this template, simply run the following tasks:
19+
* First run `npm update` to update the dependencies
20+
* Then run `gulp copy` to copy the new versions to their proper destinations
21+
22+
## Bugs and Issues
23+
24+
Have a bug or an issue with this template? [Open a new issue](https://github.com/BlackrockDigital/startbootstrap-agency/issues) here on GitHub or leave a comment on the [template overview page at Start Bootstrap](http://startbootstrap.com/template-overviews/agency/).
25+
26+
## Creator
27+
28+
Start Bootstrap was created by and is maintained by **[David Miller](http://davidmiller.io/)**, Owner of [Blackrock Digital](http://blackrockdigital.io/).
29+
30+
* https://twitter.com/davidmillerskt
31+
* https://github.com/davidtmiller
32+
33+
Start Bootstrap is based on the [Bootstrap](http://getbootstrap.com/) framework created by [Mark Otto](https://twitter.com/mdo) and [Jacob Thorton](https://twitter.com/fat).
34+
35+
## Copyright and License
36+
37+
Copyright 2013-2017 Blackrock Digital LLC. Code released under the [MIT](https://github.com/BlackrockDigital/startbootstrap-agency/blob/gh-pages/LICENSE) license.

0 commit comments

Comments
 (0)