Skip to content

Commit

Permalink
Merge commit '0fb834fe787bebdbeece60c2a4e888e0b0ac35c6' into release-…
Browse files Browse the repository at this point in the history
…v0.9.x
  • Loading branch information
github-actions[bot] committed Oct 9, 2021
2 parents e78826e + 0fb834f commit 2869d99
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: yarn --frozen-lockfile --cache-folder .yarn

- name: Build runtime
run: yarn workspace @dealmore/tf-next-runtime build
run: yarn workspace @millihq/tf-next-runtime build

- name: Build tf-next
run: yarn workspace tf-next build
Expand All @@ -39,7 +39,7 @@ jobs:
run: yarn workspace @millihq/terraform-next-proxy build

- name: Build deploy-trigger
run: yarn workspace @dealmore/terraform-next-deploy-trigger build
run: yarn workspace @millihq/terraform-next-deploy-trigger build

- name: Upload build artifacts
uses: actions/upload-artifact@v2
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.9.3 (October 09, 2021)

This release fixes the routing behavior for dynamic routes that are statically generated (served from S3).

### Proxy

- Fixes dynamic routing for statically generated routes ([#218](https://github.com/milliHQ/terraform-aws-next-js/issues/218), [#221](https://github.com/milliHQ/terraform-aws-next-js/pull/221))

## 0.9.2 (September 19, 2021)

⚠️ Namespace changed ⚠️
Expand Down
156 changes: 156 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Contributing

Contributions are welcome!

As a general advice it is always a good idea to raise an [issue](https://github.com/milliHQ/terraform-aws-next-js/issues) before creating a new pull request.
This ensures that we don't have to reject pull requests that are not aligning with our roadmap and not wasting your valuable time.

## Contribution Prerequisites

The project is a monorepo which contains both the Terraform module and the CLI (`tf-next`) that is used to prepare the Next.js to be served by AWS Lambda written in Node.js.
It also contains components (`proxy` and `deploy-trigger`) that are directly published to AWS Lambda. They are also written in Node.js.

For the Terraform part you should have installed:

- [Terraform CLI](https://www.terraform.io/downloads.html) at 0.13+

For the CLI and the components you should have installed:

- [Node.js](https://nodejs.org/) at v14.0.0+
- [Yarn 1](https://classic.yarnpkg.com/) at v1.2.0+

## Development Workflow

### Terraform module

> **Note:** You should not make changes to the documentation of the **Requirements**, **Providers**, **Inputs** and **Outputs** sections in the `README.md` when contributing.
> The values there are auto generated by a GitHub action task once a PR is merged.
#### Codestyle

We use a [GitHub Action](https://github.com/milliHQ/terraform-aws-next-js/actions/workflows/lint.yml) to make sure that the committed code is properly formatted.
Before submitting a PR, you should make sure that the code is properly formatted.

You can do this by running the Terraform [`fmt` command](https://www.terraform.io/docs/cli/commands/fmt.html) in the root of the repository:

```sh
terraform fmt -recursive
```

### CLI and components

After cloning the repository, run `yarn` to fetch and install its dependencies.

## Testing

Automatic testing is only done for the worker component written in Node.js.
The Terraform module is **not** covered by automatic tests.

### Testing Terraform module

Since the Terraform module itself is not covered by automatic tests, testing has to be done manually.
The repository contains some examples in the [`examples/*`](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples) folder, that can be used to run a quick acceptance test against your own AWS account.

You may need to change a few settings in the `main.tf` file in the root of the example:

#### Use local development version of the module

To use the local development version instead of downloading it from the Terraform registry you have to change the source to the local path of the module.
When working with one of the examples zou can simply use the relative path to the root of the cloned repository:

```diff
module "tf_next" {
- source = "milliHQ/next-js/aws"
+ source = "../.."
...
}
```

#### Use local build of the components

Instead of downloading the components from npm you can also specify the `debug_use_local_packages` to use the local version.
To do so, make sure that the components are built by running the following commands:

```sh
yarn --cwd packages/proxy build
yarn --cwd packages/deploy-trigger build
```

After that you should have a `dist.zip` file in the root of each package.

To deploy the local built components, you also need to set `debug_use_local_packages = true`:

```diff
module "tf_next" {
source = "../.."
...
+ debug_use_local_packages = true
}
```

### End-to-end (e2e) testing (CLI + components)

The end-to-end testing is only used for testing the the CLI (`tf-next`) and components (`proxy` and `deploy-trigger`).
A local environment of AWS Lambda is created for this to simulate a execution under the same conditions as it would run in a AWS data center.

#### 0. Prerequisites

- [Docker Desktop + Docker Compose](https://www.docker.com/products/docker-desktop)
(Docker Compose comes bundled with Docker Desktop on MacOS and Windows)
- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)

You should check after install if they are available from your command-line:

```sh
docker --version
# > Docker version 20.10.2, build 2291f61

docker-compose --version
# > docker-compose version 1.27.4, build 40524192

sam --version
# > SAM CLI, version 1.17.0
```

#### 1. Build the CLI & components

Before running a e2e-test make sure that the CLI and the components are built:

```sh
# CLI (Order is important here!)
yarn --cwd packages/runtime build
yarn --cwd packages/tf-next build

# Components
yarn --cwd packages/proxy build
yarn --cwd packages/deploy-trigger build
```

#### 2. Build the fixtures

The fixtures are real Next.js apps that need to be built with `tf-next build` before passing them to the e2e-test.
You can build all fixtures by running:

```sh
yarn test:e2e:prepare
```

#### 3. Local S3 instance

Before running the e2e-tests, make sure that the local S3 emulator from docker-compose is running.
From the root of the project run:

```sh
docker-compose up -d
```

#### 4. Run tests

After that you should be able to execute the e2e-tests locally by running the `test:e2e` task:

```sh
yarn test:e2e
```

The e2e-tests are executed from the `test/routes.test.ts` file.
Each fixture in `test/fixtures/*` contains a `probes.json` file that contains the actual test cases.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ A zero-config Terraform module for self-hosting Next.js sites serverless on AWS

Some features are still under development, here is a list of features that are currently supported and what we plan to bring with the next releases:

- Next.js `v9.5+` & `v10+` _(older Versions might work but are not actively supported)_
- Terraform `v0.13+`
- [Next.js](https://nextjs.org/) 11, 10 & 9 support
- [Terraform](https://www.terraform.io/) `v0.13+`
- Static, SSG, Lambda and API pages (with [dynamic routes](https://nextjs.org/docs/routing/dynamic-routes))
- Automatic expiration of old static assets
- [Rewrites](https://nextjs.org/docs/api-reference/next.config.js/rewrites) & [Redirects](https://nextjs.org/docs/api-reference/next.config.js/redirects)
- [Image Component & Image Optimization](https://nextjs.org/docs/basic-features/image-optimization) support
- 🚧  [Incremental Static Regeneration](https://nextjs.org/docs/basic-features/data-fetching#incremental-static-regeneration)
- 🚧  [AWS CodeDeploy](https://aws.amazon.com/codedeploy/)

## Architecture

Expand Down Expand Up @@ -281,6 +280,11 @@ So issues that exist on Vercel are likely to occur on this project too.

You should be able to run`terraform apply` again and the stack creation would progreed without this error.

## Contributing

Contributions are welcome!
If you want to improve this module, please take a look at our [contributing guidelines](https://github.com/milliHQ/terraform-aws-next-js/tree/main/CONTRIBUTING.md) to get started.

## License

Apache-2.0 - see [LICENSE](./LICENSE) for details.
Expand Down
2 changes: 1 addition & 1 deletion modules/proxy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

variable "proxy_module_version" {
type = string
default = "0.8.0"
default = "0.9.3"
}

variable "lambda_default_runtime" {
Expand Down
2 changes: 1 addition & 1 deletion modules/statics-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module "lambda_content" {
source = "milliHQ/download/npm"
version = "2.0.0"

module_name = "@dealmore/terraform-next-deploy-trigger"
module_name = "@millihq/terraform-next-deploy-trigger"
module_version = var.deploy_trigger_module_version
path_to_file = "dist.zip"
use_local = var.debug_use_local_packages
Expand Down
2 changes: 1 addition & 1 deletion modules/statics-deploy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "static_files_archive" {

variable "deploy_trigger_module_version" {
type = string
default = "0.4.0"
default = "0.9.3"
}

variable "expire_static_assets" {
Expand Down

0 comments on commit 2869d99

Please sign in to comment.