feat: add Fractal files
This commit is contained in:
parent
06d6697939
commit
35837b6c3f
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
README.md
|
8
.env.example
Normal file
8
.env.example
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
export DOCKER_UID=1000
|
||||
|
||||
export COMPOSE_PROJECT_NAME=docker-example-fractal
|
||||
export COMPOSE_PROFILES=node
|
||||
|
||||
export DOCKER_WEB_VOLUME=.:/app
|
25
.githooks/prepare-commit-msg
Executable file
25
.githooks/prepare-commit-msg
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
# Load the issue ID from an `.issue-id` file within the project and replace the
|
||||
# `ISSUE_ID` placeholder within a Git commit message.
|
||||
#
|
||||
# For example, running `echo "OD-123" > .issue-id` will add `Refs: OD-123` to
|
||||
# the commit message.
|
||||
#
|
||||
# This also works with multiple issue IDs in the same string, e.g.
|
||||
# "OD-123 OD-456", or IDs on multiple lines.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_DIR=$(git rev-parse --show-toplevel)
|
||||
ISSUE_FILE="$PROJECT_DIR/.issue-id"
|
||||
|
||||
if [ -f "${ISSUE_FILE}" ]; then
|
||||
ISSUE_IDS=$(cat "${ISSUE_FILE}" | tr '\n' ',' | tr ' ' ',' | sed 's/,$//' | sed 's/,/, /g')
|
||||
|
||||
if [ -n "${ISSUE_IDS}" ]; then
|
||||
sed -i.bak "s/# Refs:/Refs: $ISSUE_IDS/" "$1"
|
||||
fi
|
||||
fi
|
25
.github/workflows/ci.yml
vendored
Normal file
25
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
COMPOSE_DOCKER_CLI_BUILD: 1
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_UID: 1001
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
name: Build and test
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||
|
||||
- name: Build and test
|
||||
run: |
|
||||
./run ci:build
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
node_modules
|
||||
|
||||
.env
|
||||
docker-compose.override.yaml
|
2
.hadolint.yaml
Normal file
2
.hadolint.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
ignore:
|
||||
- DL3059
|
3
.yarnrc
Normal file
3
.yarnrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
--modules-folder /node_modules
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
FROM node:20-bullseye-slim AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /node_modules \
|
||||
&& chown node:node -R /app /node_modules
|
||||
|
||||
COPY --chown=node:node package*.json *yarn* /app
|
||||
|
||||
USER node
|
||||
|
||||
################################################################################
|
||||
|
||||
FROM base AS build
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
COPY --chown=node:node . .
|
||||
|
||||
CMD ["bash"]
|
13
build.yaml
Normal file
13
build.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
name: docker-example-fractal
|
||||
language: javascript
|
||||
type: fractal
|
||||
|
||||
node:
|
||||
version: 20-bullseye-slim
|
||||
|
||||
docker-compose:
|
||||
services:
|
||||
web: false
|
||||
|
||||
experimental:
|
||||
createGitHubActionsConfiguration: true
|
0
components/.keep
Normal file
0
components/.keep
Normal file
5
docker-compose.override.yaml.example
Normal file
5
docker-compose.override.yaml.example
Normal file
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
node:
|
||||
command: "yarn fractal start --sync --port ${DOCKER_WEB_PORT:-3000}"
|
||||
ports:
|
||||
- "${DOCKER_WEB_PORT:-3000}:${DOCKER_WEB_PORT:-3000}"
|
44
docker-compose.yaml
Normal file
44
docker-compose.yaml
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
x-proxy: &default-proxy
|
||||
networks:
|
||||
- default
|
||||
- web
|
||||
labels:
|
||||
- "traefik.docker.network=traefik_proxy"
|
||||
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
|
||||
`${COMPOSE_PROJECT_NAME}.localhost`,
|
||||
)"
|
||||
|
||||
x-app: &default-app
|
||||
volumes:
|
||||
- "${DOCKER_WEB_VOLUME:-./:/app}"
|
||||
env_file:
|
||||
- .env
|
||||
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
|
||||
networks:
|
||||
- default
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${DOCKER_MYSQL_CPUS:-0}"
|
||||
memory: "${DOCKER_MYSQL_MEMORY:-0}"
|
||||
labels:
|
||||
- "traefik.enabled=false"
|
||||
tty: true
|
||||
|
||||
services:
|
||||
|
||||
node:
|
||||
<<: [*default-proxy, *default-app]
|
||||
build:
|
||||
context: .
|
||||
target: build
|
||||
volumes:
|
||||
- .:/app
|
||||
profiles: [node]
|
||||
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
name: traefik_proxy
|
0
docs/.keep
Normal file
0
docs/.keep
Normal file
51
fractal.config.js
Normal file
51
fractal.config.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
"use strict"
|
||||
|
||||
const fractal = (module.exports = require("@frctl/fractal").create())
|
||||
const mandelbrot = require("@frctl/mandelbrot")
|
||||
const path = require("path")
|
||||
|
||||
fractal.set("project.title", "docker-example-fractal")
|
||||
|
||||
const twig = require("@frctl/twig")({
|
||||
functions: {
|
||||
modify(baseClass, modifiers = []) {
|
||||
// Ensure we have an array of modifiers.
|
||||
const modifiersArray = Array.isArray(modifiers) ? modifiers : [modifiers]
|
||||
|
||||
// Loop over them and prepend the baseclass.
|
||||
const classArray = modifiersArray.map(
|
||||
(modifier) => `${baseClass}--${modifier}`
|
||||
)
|
||||
classArray.unshift(baseClass)
|
||||
return classArray.join(" ")
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
fractal.components.engine(twig)
|
||||
fractal.components.set("default.preview", "@preview")
|
||||
fractal.components.set("ext", ".twig")
|
||||
|
||||
fractal.components.set("path", path.join(__dirname, "components"))
|
||||
|
||||
fractal.docs.engine("@frctl/twig")
|
||||
fractal.docs.set("path", path.join(__dirname, "docs"))
|
||||
|
||||
fractal.web.set("builder.dest", path.join(__dirname, "build"))
|
||||
fractal.web.set("static.path", path.join(__dirname, "public"))
|
||||
|
||||
fractal.web.theme(
|
||||
mandelbrot({
|
||||
format: "yaml",
|
||||
lang: "en-GB",
|
||||
skin: {
|
||||
name: 'default',
|
||||
accent: '#114b71',
|
||||
complement: '#fff',
|
||||
links: '#114b71',
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
fractal.components.set('default.status', 'wip');
|
||||
fractal.components.set('statuses.wip.label', 'Work in progress');
|
8
package.json
Normal file
8
package.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@frctl/fractal": "^1.5.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@frctl/twig": "^1.2.13"
|
||||
}
|
||||
}
|
108
run
Executable file
108
run
Executable file
|
@ -0,0 +1,108 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
PATH="$PATH:./node_modules/.bin"
|
||||
|
||||
# If we're running in CI we need to disable TTY allocation for docker compose
|
||||
# commands that enable it by default, such as exec and run.
|
||||
TTY="${TTY:-}"
|
||||
if [[ ! -t 1 ]]; then
|
||||
TTY="-T"
|
||||
fi
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function build {
|
||||
cmd fractal build "${@}"
|
||||
}
|
||||
|
||||
function ci:build {
|
||||
docker compose up -d
|
||||
|
||||
build
|
||||
|
||||
cmd tree /app/build
|
||||
}
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function clean {
|
||||
rm -fr build node_modules
|
||||
touch build/.keep
|
||||
}
|
||||
|
||||
# Disable Git hooks.
|
||||
function git-hooks:off {
|
||||
git config --unset core.hooksPath
|
||||
}
|
||||
|
||||
# Enable Git hooks.
|
||||
function git-hooks:on {
|
||||
git config core.hooksPath .githooks
|
||||
}
|
||||
|
||||
# Create a new Fractal component.
|
||||
function fractal:new {
|
||||
mkdir -p "components/${1}"
|
||||
|
||||
echo "name: ${1}" > "components/${1}/${1}.config.yml"
|
||||
echo "${1}" > "components/${1}/${1}.twig"
|
||||
}
|
||||
|
||||
# Display a list of all available commands.
|
||||
function help {
|
||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||
|
||||
compgen -A function | grep -v "^_" | cat -n
|
||||
|
||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||
}
|
||||
|
||||
# Start the project.
|
||||
function start {
|
||||
cp -v --no-clobber .env.example .env
|
||||
docker compose up -d
|
||||
}
|
||||
|
||||
function sync {
|
||||
clean
|
||||
fractal build
|
||||
|
||||
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||
--acl "public-read" \
|
||||
--cache-control max-age=3600
|
||||
}
|
||||
|
||||
# Run a command within the node container.
|
||||
function cmd {
|
||||
docker compose exec node yarn "${@}"
|
||||
}
|
||||
|
||||
# Stop the project
|
||||
function stop {
|
||||
docker compose down
|
||||
}
|
||||
|
||||
# Execute yarn commands.
|
||||
function yarn {
|
||||
cmd node yarn "${@}"
|
||||
}
|
||||
|
||||
function _run {
|
||||
local service="${1}"
|
||||
local command="${2}"
|
||||
|
||||
docker compose run \
|
||||
--entrypoint "${command}" \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
"${service}" "${@}"
|
||||
}
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
||||
|
||||
# vim: ft=bash
|
Loading…
Reference in a new issue