Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Lagoon/Lando Services #44

Merged
merged 9 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/pr-all-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: All Services Tests

on:
pull_request:

jobs:
leia-tests:
runs-on: ${{ matrix.os }}
env:
TERM: xterm
strategy:
matrix:
leia-tests:
- examples/all-services
lando-versions:
- edge
os:
- ubuntu-22.04
node-version:
- '16'

steps:
# Install deps and cache
- name: Checkout code
uses: actions/checkout@v3
- name: Install node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

# This block should eventually become use lando/actions-hyperdrive@v2
- name: Verify Docker dependencies
run: |
docker --version | grep "20.10."
docker-compose --version | grep "1.29."
- name: Grab latest edge Lando CLI
run: |
sudo curl -fsSL -o /usr/local/bin/lando "https://files.lando.dev/cli/lando-linux-x64-${{ matrix.lando-versions }}"
sudo chmod +x /usr/local/bin/lando
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "lagoon/lagoon"
replace: ${{ github.event.repository.name }}/${{ github.event.repository.name }}
include: "actions-lando-config.yml"
regex: false
Comment on lines +43 to +49
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick note here - we needed to replace the lando-config here, as our fork of the repo isn't in a lagoon repo - so this allows the config to pick up the correct repo name

- name: Move in lando config appropriate for testing
run: |
mkdir -p ~/.lando/cache
cp -f actions-lando-config.yml ~/.lando/config.yml
echo false > ~/.lando/cache/report_errors
lando --clear
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep lagoon | grep /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }} || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)

# This block should eventually become use lando/actions-leia@v2
# @NOTE? Do we want a way for our leia-action to configure apparmor since
# this might break a whole bunch of tests? or is this literally just a thing
# for the Lagoon mysql/mariadb container?
- name: Configure apparmor
run: |
set -x
sudo apt-get remove mysql-server --purge
sudo apt-get install apparmor-profiles
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: Run leia tests
shell: bash
run: yarn leia "./${{ matrix.leia-tests }}/README.md" -c 'Destroy tests' --stdin --shell bash

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
logs

# NPM files
node_modules
/node_modules

# lando config
env.yaml
Expand Down
2 changes: 1 addition & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lando-lagoon-plugin
services:
node:
type: node:14
type: node:16
build:
- yarn install
scanner: false
Expand Down
9 changes: 6 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ Lando will read and interpret your normal `.lagoon.yml` and its associated Docke
The services we currently support with links to their associated Lagoon docs is shown below:

* [Elasticsearch](https://docs.lagoon.sh/lagoon/docker-images/elasticsearch)
* [PHP-FPM](https://docs.lagoon.sh/lagoon/docker-images/php-fpm)
* [PHP CLI](https://docs.lagoon.sh/lagoon/docker-images/php-cli)
* [Nginx](https://docs.lagoon.sh/lagoon/docker-images/nginx)
* [MariaDB](https://docs.lagoon.sh/lagoon/docker-images/mariadb)
* [Node](https://docs.lagoon.sh/docker-images/nodejs/)
* [Nginx](https://docs.lagoon.sh/lagoon/docker-images/nginx)
* [PHP CLI](https://docs.lagoon.sh/lagoon/docker-images/php-cli)
* [PHP-FPM](https://docs.lagoon.sh/lagoon/docker-images/php-fpm)
* [Python](https://docs.lagoon.sh/docker-images/python/)
* [PostgreSQL](https://docs.lagoon.sh/lagoon/docker-images/postgres)
* [Redis](https://docs.lagoon.sh/lagoon/docker-images/redis)
* [Ruby](https://docs.lagoon.sh/docker-images/ruby/)
* [Solr](https://docs.lagoon.sh/lagoon/docker-images/solr)
* [Varnish](https://docs.lagoon.sh/lagoon/docker-images/varnish)

Expand Down
Empty file.
1 change: 1 addition & 0 deletions examples/all-services/.lagoon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose-yaml: docker-compose.yml
12 changes: 12 additions & 0 deletions examples/all-services/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: all-services
recipe: lagoon
services:
node:
command: yarn run start
port: 3000
ruby:
command: ruby -run -e httpd / -p 3000
port: 3000
python:
command: python -m http.server 8800
port: 8800
19 changes: 19 additions & 0 deletions examples/all-services/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Specifies the image of your engine
FROM uselagoon/node-18:latest

# The working directory inside your container
WORKDIR /app

# Get the package.json first to install dependencies
COPY package.json yarn.lock /app/

# This will install those dependencies
RUN yarn install

# Copy the rest of the app to the working directory
COPY . /app

EXPOSE 3000

# Run the container
CMD ["yarn", "run", "start"]
68 changes: 68 additions & 0 deletions examples/all-services/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Lagoon All Services
=======================

This example exists primarily to test the following documentation:

* [Lagoon Recipe - Drupal 9](https://docs.lando.dev/config/lagoon.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should poweroff
lando poweroff

# Should start up our project successfully
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should have all the services we expect
docker ps --filter label=com.docker.compose.project | grep Up | grep allservices_node_1
docker ps --filter label=com.docker.compose.project | grep Up | grep allservices_python_1
docker ps --filter label=com.docker.compose.project | grep Up | grep allservices_ruby_1

# Should have the correct environment set
lando ssh -u root -c "env" | grep LAGOON_ROUTE
lando ssh -u root -c "env" | grep LAGOON_ENVIRONMENT_TYPE | grep development

# Should have node
lando node --version

# Should have npm
lando npm --version

# Should have yarn
lando yarn --version

# Should have lagoon cli
lando lagoon --version | grep lagoon

# Should have a running node service
curl -kL http://node.all-services.lndo.site/ | grep "LAGOON="

# # Should have a running python service
curl -kL http://python.all-services.lndo.site/ | grep "lagoon/"

# # Should have a running ruby service
curl -kL http://ruby.all-services.lndo.site/ | grep "Ruby/"
curl -kL http://ruby.all-services.lndo.site/ | grep "lagoon/"
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be able to destroy the project successfully
lando destroy -y
lando poweroff
```
57 changes: 57 additions & 0 deletions examples/all-services/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: "2.3"

x-environment:
&default-environment
LAGOON_PROJECT: "all-services"
# Route that should be used locally
LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-all-services}.docker.amazee.io
# Uncomment if you like to have the system behave like in production
LAGOON_ENVIRONMENT_TYPE: development
# Uncomment to enable xdebug and then restart via `docker-compose up -d`
#XDEBUG_ENABLE: "true"
HTTP_HOST: *default-url

x-user:
&default-user
# The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000`
user: '1000'

services:
node:
build:
context: .
dockerfile: Dockerfile
labels:
lagoon.type: node
lando.type: node
ports:
- "3000"
user: root
environment:
<< : *default-environment # loads the defined environment variables from the top
networks:
- default

python:
image: uselagoon/python-3.11:latest
labels:
lagoon.type: python
lando.type: python
ports:
- "8800"
environment:
<< : *default-environment # loads the defined environment variables from the top
networks:
- default

ruby:
image: uselagoon/ruby-3.0:latest
labels:
lagoon.type: ruby
lando.type: ruby
ports:
- "3000"
environment:
<< : *default-environment # loads the defined environment variables from the top
networks:
- default
13 changes: 13 additions & 0 deletions examples/all-services/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {createServer} from 'http';
// create a server object:
createServer(function(req, res) {
let result = [];
Object.keys(process.env).map(key => {
result.push(`${key}=${process.env[key]}`);
});
res.setHeader('Content-type', 'text/html');
res.write(result.join(`<br/>`));
res.end(); // end the response
}).listen(3000, function() {
console.log('server start at port 3000'); // the server object listens on port 3000
});
13 changes: 13 additions & 0 deletions examples/all-services/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "node",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type":"module",
"dependencies": {
"express": "^4.17.1"
},
"scripts": {
"start": "node index.js"
}
}