Skip to content

Commit

Permalink
Merge branch 'release/9.0.0-beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
marteinn committed Feb 4, 2024
2 parents db6f6cc + 9210495 commit f2b9326
Show file tree
Hide file tree
Showing 68 changed files with 4,814 additions and 7,057 deletions.
63 changes: 20 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,51 @@
name: Test cookiecutter scaffolder
on: [push, pull_request]
jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
experimental_use_app_router: [
{name: "Page router", value: "False"},
{name: "App router", value: "True"},
]
name: Test ${{ matrix.experimental_use_app_router.name }}
steps:
- uses: actions/checkout@v4
- uses: "actions/setup-python@v4"
- uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: Install cookiecutter
run: |
python -m pip install --upgrade pip
pip install cookiecutter
- name: Run cookiecutter
- name: Cleanup
run: |
set -x
rm -rf Company-Project
cookiecutter . --no-input
- name: Archive generated-project
uses: actions/upload-artifact@v3
with:
name: generated-project
path: ./Company-Project
retention-days: 1

backend:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rm -rf Company-Project
- name: Restore generated-project
uses: actions/download-artifact@v3
with:
name: generated-project
path: Company-Project
- name: Run cookiecutter
run: |
cookiecutter . --no-input experimental_use_app_router=${{ matrix.experimental_use_app_router.value }}
- name: Create docker-compose config for running boilerplate tests
run: |
cp docker-compose-circleci.yml Company-Project/docker-compose-circleci.yml
cp docker-compose-ci.yml Company-Project/docker-compose-ci.yml
- name: Build image
run: |
cd Company-Project
chmod +x src/docker-entrypoint.sh
docker-compose -f docker-compose-circleci.yml build
docker-compose -f docker-compose-ci.yml build
- name: Verify backend scaffolder
run: |
cd Company-Project
set -x
docker-compose -f docker-compose-circleci.yml run --rm python python manage.py new_page --name=Article
docker-compose -f docker-compose-ci.yml run --rm python python manage.py new_page --name=Article
- name: Run tests on container
run: |
cd Company-Project
docker-compose -f docker-compose-circleci.yml run --rm python test
docker-compose -f docker-compose-circleci.yml run --rm python typecheck
docker-compose -f docker-compose-circleci.yml run --rm python lint
frontend:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: "actions/setup-node@v4"
with:
node-version: "20"
- run: rm -rf Company-Project
- name: Restore generated-project
uses: actions/download-artifact@v3
with:
name: generated-project
path: Company-Project
docker-compose -f docker-compose-ci.yml run --rm python test
docker-compose -f docker-compose-ci.yml run --rm python typecheck
docker-compose -f docker-compose-ci.yml run --rm python lint
- name: Run frontend tests
run: |
cd Company-Project/frontend
Expand Down
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Removed

## [9.0.0-beta] - 2024-02-04

### Added
- Add experimental app router support (@marteinn)
- Add production ready python docker image with gunicorn (@mikaelengstrom)
- Add container for Next.js frontend (@mikaelengstrom)

### Changed
- Return seo robots as struct to prepare for Next.js metadata api (@marteinn)
- Pass host as query param as Next.js will drop header in app router (@marteinn)
- Change nginx docker image from alpine to latest to avoid permisson issues (@mikaelengstrom)
- Move env utils from pipit.env_utils to namespace utils.env (@mikaelengstrom @marteinn)
- Move if_exists_load_env to env.utils (@mikaelengstrom @marteinn)
- Load .env file in wsgi.oy (@mikaelengstrom)
- Use whitenoise when serving static assets on stage/prod (@mikaelengstrom @marteinn)
- Add pytest as a direct dependency (@marteinn)
- Run next.js in standalone mode (@mikaelengstrom @marteinn)

### Fixed
- Upgrade storybook to 7.6.10
- Upgrade prettier to 3.2.4
- Upgrade pretty-quick to 4.0.0
- Upgrade eslint and related packages
- Upgrade i18next and related packages
- Upgrade husky to 9.0.6
- Upgrade @sentry/nextjs to 7.98.0
- Upgrade @testing-library and related packages
- Upgrade @swc/jest to 0.2.31
- Upgrade pytest-django to 4.8.0
- Update actions/setup-python to v5 in CI runner
- Upgrade psycopg to 3.1.17

### Removed
- Drop classnames dependecy as its not used in the boilerplate (@marteinn)
- Drop @storybook/react dependecy as it's already included by @storybook/nextjs (@marteinn)
- Drop react-i18next as it's already included by next-i18next (@marteinn)
- Drop react-i18next as it's already included by next-i18next (@marteinn)
- Drop unused css-loader and style-loader (@marteinn)
- Drop @swc/core dependecy as it's already included in Next.js (@marteinn)
- Drop unused @types/react (@marteinn)

## [8.15.0] - 2024-01-25

### Added
Expand Down
4 changes: 0 additions & 4 deletions Company-Project/.githooks/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ rm src/pipit/settings/base.py.bak
sed -i.bak 's/^\( *\)"version": .*/\1"version": "'$VERSION'",/' $ROOTDIR/frontend/package.json
rm frontend/package.json.bak

# Bump docker version
sed -i.bak 's/^LABEL version=.*/LABEL version="v'$VERSION'"/' $ROOTDIR/src/Dockerfile
rm src/Dockerfile.bak

# Commit changes
git commit -a -m "Version bump $VERSION"

Expand Down
3 changes: 1 addition & 2 deletions Company-Project/deploy/files/pm2_config.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apps:
- name: {{ project_slug }}
script: {{ ansistrano_deploy_to }}/current/src/frontend/node_modules/next/dist/bin/next
args: start
script: {{ ansistrano_deploy_to }}/current/src/frontend/.next/standalone/server.js
cwd: {{ ansistrano_deploy_to }}/current/src/frontend/
exec_mode: cluster
instances: 0
Expand Down
12 changes: 9 additions & 3 deletions Company-Project/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.1"
services:
web:
image: nginx:alpine
image: nginx:latest
working_dir: /app
ports:
- "8081:80"
Expand All @@ -20,9 +20,15 @@ services:

python:
image: frojd/company_project_python
build: ./src
build:
context: ./src
args:
- ENVIRONMENT=local
command: "runserver"
volumes:
- "./src:/app"
- "./src:/home/app/web"
- "./src/media:/home/app/media"
- "./src/static:/home/app/static"
depends_on:
- db
env_file: ./docker/config/python.env
Expand Down
10 changes: 6 additions & 4 deletions Company-Project/docker/files/config/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ server {
# rewrite "^/wt/media/(.*)$" "https://${MEDIA_REMOTE_DOMAIN}/wt/media/$1" redirect;
# }

location /wt/static/ {
expires 30d;
alias /app/static/;
}
# Uncomment if you do not wish to serve statics with whitenoise
#
# location /wt/static/ {
# expires 30d;
# alias /app/static/;
# }

location / {
proxy_set_header Host $host:8081;
Expand Down
42 changes: 42 additions & 0 deletions Company-Project/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM node:20-alpine as BUILD_IMAGE
WORKDIR /app
COPY package.json package-lock.json ./
# install dependencies
RUN npm ci --audit=false
RUN npm rebuild --arch=x64 --platform=linux --libc=musl sharp

COPY . .

# build
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV production
ENV NEXT_SHARP_PATH=/app/.next/standalone/node_modules/sharp

RUN npm run build

FROM node:20-alpine
WORKDIR /app

RUN apk update && apk add --no-cache dumb-init

RUN addgroup -S app && adduser -S app -G app

ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV production

# copy from build image

COPY --from=BUILD_IMAGE /app/.next/standalone ./standalone
COPY --from=BUILD_IMAGE /app/.next/static ./standalone/.next/static
COPY --from=BUILD_IMAGE /app/public ./standalone/public

EXPOSE 3000

RUN chown -R app:app /app
USER app

ENV NEXT_SHARP_PATH=/app/standalone/node_modules/sharp
ENV NODE_ENV production


CMD ["dumb-init", "node", "./standalone/server.js"]
20 changes: 19 additions & 1 deletion Company-Project/frontend/api/wagtail.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,25 @@ export async function getRequest(url, params, options) {
...headers,
};
const queryString = querystring.stringify(params);
const res = await fetch(`${url}?${queryString}`, { headers });

let fetchOptions = { headers };

if (options?.cache) {
fetchOptions = {
...fetchOptions,
cache: options.cache,
};
}

if (options?.revalidate) {
fetchOptions = {
...fetchOptions,
next: {
revalidate: options.revalidate,
},
};
}
const res = await fetch(`${url}?${queryString}`, fetchOptions);

if (res.status < 200 || res.status >= 300) {
const error = new WagtailApiResponseError(res, url, params);
Expand Down
Loading

0 comments on commit f2b9326

Please sign in to comment.