-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
273 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: docker-fractal | ||
language: javascript | ||
type: fractal | ||
|
||
node: | ||
version: 20-bullseye-slim | ||
|
||
dockerfile: [] | ||
|
||
docker-compose: | ||
services: | ||
- node | ||
|
||
experimental: | ||
createGitHubActionsConfiguration: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. | ||
|
||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-fractal | ||
export COMPOSE_PROFILES=node | ||
|
||
export DOCKER_WEB_VOLUME=.:/app |
27 changes: 27 additions & 0 deletions
27
tests/snapshots/output/fractal/.githooks/prepare-commit-msg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/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 -o errexit | ||
set -o nounset | ||
set -o 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
name: Build | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | ||
|
||
- name: Build | ||
run: | | ||
./run ci:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. | ||
|
||
node_modules | ||
|
||
# Docker. | ||
.env | ||
docker-compose.override.yaml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- DL3059 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. | ||
|
||
--modules-folder /node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
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 { | ||
cp -v --no-clobber .env.example .env | ||
|
||
docker network create traefik_proxy || true | ||
|
||
docker compose up -d | ||
|
||
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}" "${@}" | ||
} | ||
|
||
# Include any local tasks. | ||
[[ -e run.local ]] && source run.local | ||
|
||
TIMEFORMAT=$'\nTask completed in %3lR' | ||
time "${@:-help}" | ||
|
||
# vim: ft=bash |