Skip to content

Commit

Permalink
Implement buildpack (#3)
Browse files Browse the repository at this point in the history
* Implement buildpack

Signed-off-by: Rob Dimsdale-Zucker <[email protected]>

* add an offline test

* Update README.md

Co-authored-by: Tim Hitchener <[email protected]>

* Update README.md

Co-authored-by: Tim Hitchener <[email protected]>

* modify provision name to include php

* manually update github config

* Update README.md

Co-authored-by: Rob Dimsdale-Zucker <[email protected]>
Co-authored-by: Tim Hitchener <[email protected]>
  • Loading branch information
3 people authored Apr 1, 2022
1 parent d2ebbd0 commit 1c290e5
Show file tree
Hide file tree
Showing 38 changed files with 3,054 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/approve-bot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Checkout
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Approve
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Fetch Pull Request Details
id: pull_request
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2.2.0
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Run Unit Tests
run: ./scripts/unit.sh

Expand All @@ -34,11 +34,11 @@ jobs:
needs: unit
steps:
- name: Setup Go
uses: actions/setup-go@v2.2.0
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Run Integration Tests
run: ./scripts/integration.sh --use-token
Expand All @@ -51,11 +51,11 @@ jobs:
needs: integration
steps:
- name: Setup Go
uses: actions/setup-go@v2.2.0
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Reset Draft Release
id: reset
Expand All @@ -70,6 +70,7 @@ jobs:
with:
repo: ${{ github.repository }}
token: ${{ github.token }}
ref-name: ${{ github.ref_name }}
- name: Set Release Tag
id: tag
run: |
Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
name: Auto-label PR
name: Set / Validate PR Labels
on:
pull_request:
branches:
- main
types:
- synchronize
- opened
- reopened
- labeled
- unlabeled

concurrency: pr_labels
concurrency: pr_labels_${{ github.event.number }}

jobs:
semver-label:
name: Semver Auto-Label
autolabel:
name: Ensure Minimal Semver Labels
runs-on: ubuntu-latest
steps:
- name: Check Minimal Semver Labels
uses: mheap/github-action-required-labels@v1
with:
count: 1
labels: semver:major, semver:minor, semver:patch
mode: exactly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-label Semver
if: ${{ failure() }}
uses: paketo-buildpacks/github-config/actions/pull-request/auto-semver-label@main
env:
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/lint-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
lintYaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Checkout github-config
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: paketo-buildpacks/github-config
path: github-config

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: 3.8

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x

- name: Checkout
uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
uses: golangci/golangci-lint-action@v3
with:
version: v1.32.2
version: v1.45.2
2 changes: 1 addition & 1 deletion .github/workflows/synchronize-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ github.token }}
12 changes: 6 additions & 6 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2.2.0
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.18.x

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Run Unit Tests
run: ./scripts/unit.sh
Expand All @@ -27,12 +27,12 @@ jobs:
needs: unit
steps:
- name: Setup Go
uses: actions/setup-go@v2.2.0
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.18.x

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ name: Update dependencies

on:
schedule:
- cron: '*/15 * * * *'
- cron: '15 */1 * * *'
workflow_dispatch: {}

concurrency: dependency_update

jobs:
update-dependencies:
runs-on: ubuntu-latest
name: Update dependencies
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Checkout Branch
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/update-github-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ on:
- cron: '30 1 * * *'
workflow_dispatch: {}

concurrency: github_config_update

jobs:
build:
name: Create PR to update shared files
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

- name: Checkout github-config
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: paketo-buildpacks/github-config
path: github-config
Expand Down
8 changes: 8 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (c) 2018-Present CloudFoundry.org Foundation, Inc. All Rights Reserved.

This project is licensed to you under the Apache License, Version 2.0 (the "License").
You may not use this project except in compliance with the License.

This project may include a number of subcomponents with separate copyright notices
and license terms. Your use of these subcomponents is subject to the terms and
conditions of the subcomponent's license, as noted in the LICENSE file.
82 changes: 80 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,80 @@
# php-nginx
PHP Nginx Cloud Native Buildpack
# PHP Nginx Cloud Native Buildpack
A Cloud Native Buildpack for configuring Nginx settings for PHP apps.

The buildpack generates the Nginx configuration file with the minimal set of
options to get Nginx to work with FPM (FastCGI Process Manager), and
incorporates configuration from users and environment variables. The final
Nginx configuration file is available at
`/workspace/nginx.conf`, or locatable
through the buildpack-set `$PHP_NGINX_PATH` environment variable at
launch-time.

## Integration

The PHP Nginx CNB provides `php-nginx-config`, which can be required by subsequent
buildpacks. In order to configure Nginx, the user must declare the intention to
use Nginx as the web-server by setting the `$BP_PHP_SERVER` environment
variable to `nginx` at build-time.

```shell
pack build my-nginx-app --env BP_PHP_SERVER="nginx"
```

## Nginx Configuration Sources
The base configuration file generated in this buildpack includes some default configuration, FPM-specific configuration, and
has `include` sections for user-included configuration.

#### FPM-specific Configuration
This buildpack is written to provide Nginx configuration that should always be
used in conjunction with FPM. The Nginx configuration file is generated to
include FPM-specific configuration. This buildpack also sets up an FPM
configuration file with Nginx-specific socket settings and makes it available
in the `/workspace`.

#### User Included Configuration
User-included configuration should be found in the application source directory
under `<app-directory>/.nginx.conf.d/`. Server-specific configuration should be
inside a file named `*-server.conf`, and HTTP configuration should be inside a
file with the naming structure `*-http.conf`.

If files at these paths exist, it
will be included in `include` sections at the appropriate places in the generated
Nginx configuration.

#### Environment Variables
The following environment variables can be used to override default settings in
the Nginx configuration file.

| Variable | Default |
| -------- | -------- |
| `BP_PHP_ENABLE_HTTPS_REDIRECT` | true |
| `BP_PHP_WEB_DIR` | htdocs |

## Usage

To package this buildpack for consumption:

```
$ ./scripts/package.sh
```

This builds the buildpack's Go source using `GOOS=linux` by default. You can
supply another value as the first argument to `package.sh`.

## Run Tests

To run all unit tests, run:
```
./scripts/unit.sh
```

To run all integration tests, run:
```
./scripts/integration.sh
```

## Debug Logs
For extra debug logs from the image build process, set the `$BP_LOG_LEVEL`
environment variable to `DEBUG` at build-time (ex. `pack build my-app --env
BP_LOG_LEVEL=DEBUG` or through a [`project.toml`
file](https://github.com/buildpacks/spec/blob/main/extensions/project-descriptor.md).
Loading

0 comments on commit 1c290e5

Please sign in to comment.