Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki authored Oct 12, 2024
0 parents commit 556c3d5
Show file tree
Hide file tree
Showing 49 changed files with 1,190 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Lint/NotNil:
Enabled: false

Style/RedundantReturn:
Enabled: false

# exclude all files in vendor/cache
Globs:
- "**/*.cr"
- "!vendor"
- "!tmp"
1 change: 1 addition & 0 deletions .crystal-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.13.2
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
docs/
vendor/.cache/
vendor/shards/install/
vendor/ci/bin/
.github/
bin/
data/
LICENSE
Makefile
README.md
SECURITY.md
docker-compose.yml
docker-compose.override.yml
docker-compose.production.yml
tmp/
.ameba.yml
script/release
script/deploy
script/update
script/lint
script/format
script/acceptance
script/all
script/test
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cr text eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @GrantBirki
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
---
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
groups:
github-actions:
patterns:
- "*"
schedule:
interval: monthly
34 changes: 34 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: acceptance

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
acceptance:
name: acceptance
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: fetch crystal version
id: crystal-version
run: echo "crystal=$(cat .crystal-version)" >> $GITHUB_OUTPUT

- name: install crystal
uses: crystal-lang/[email protected]
with:
crystal: ${{ steps.crystal-version.outputs.crystal }}

- name: bootstrap
run: script/bootstrap --ci

- name: acceptance
run: script/acceptance
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: build

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
build:
name: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: fetch crystal version
id: crystal-version
run: echo "crystal=$(cat .crystal-version)" >> $GITHUB_OUTPUT

- name: install crystal
uses: crystal-lang/[email protected]
with:
crystal: ${{ steps.crystal-version.outputs.crystal }}

- name: bootstrap
run: script/bootstrap --ci

- name: build
run: script/build
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: lint

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
lint:
name: lint
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: fetch crystal version
id: crystal-version
run: echo "crystal=$(cat .crystal-version)" >> $GITHUB_OUTPUT

- name: install crystal
uses: crystal-lang/[email protected]
with:
crystal: ${{ steps.crystal-version.outputs.crystal }}

- name: bootstrap
run: script/bootstrap --ci

- name: lint
run: script/lint

- name: format check
run: script/format --check
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
test:
name: test
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: fetch crystal version
id: crystal-version
run: echo "crystal=$(cat .crystal-version)" >> $GITHUB_OUTPUT

- name: install crystal
uses: crystal-lang/[email protected]
with:
crystal: ${{ steps.crystal-version.outputs.crystal }}

- name: bootstrap
run: script/bootstrap --ci

- name: test
run: script/test
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# crystal
.cache/shards/*
tmp/
bin/
!vendor/bin/
!vendor/darwin_arm64/bin/
!vendor/darwin_x86_64/bin/
!vendor/linux_x86_64/bin/
.shards/
*.dwarf
dist/
vendor/shards/install
vendor/.cache

# non-critical vendored crystal files
lib/**/.github/
lib/**/docs/
lib/**/examples/
lib/**/spec/

# secrets
creds.env
*.pem
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This ARG is for the version of the Crystal image to use - the "latest" tag is overwritable via the .crystal-version file
ARG CRYSTAL_VERSION="latest"

FROM crystallang/crystal:${CRYSTAL_VERSION} AS builder

WORKDIR /app

RUN apt-get update && apt-get install -y unzip wget

# install yq
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq

# copy the crystal version file
COPY .crystal-version .crystal-version

# copy core scripts
COPY script/ script/

# copy all vendored dependencies
COPY vendor/shards/cache/ vendor/shards/cache/

# copy shard files
COPY shard.lock shard.lock
COPY shard.yml shard.yml

# bootstrap the project
RUN script/bootstrap --production

# copy all source files (ensure to use a .dockerignore file for efficient copying)
COPY . .

# build the project
RUN script/build --production

FROM crystallang/crystal:${CRYSTAL_VERSION}

# add curl for healthchecks
RUN apt-get update && apt-get install -y curl

# create a non-root user for security
RUN useradd -m nonroot
USER nonroot

WORKDIR /app

######### CUSTOM SECTION PER PROJECT #########

# copy the binary from the builder stage
COPY --from=builder --chown=nonroot:nonroot /app/bin/crystal-base-template .

# run the binary (adds two numbers together)
CMD ["./crystal-base-template", "234122314", "1234"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Grant Birkinbine

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
run:
@echo "\033[0;34m[#] Killing old docker processes\033[0m"
docker compose down -v -t 1

@echo "\033[0;34m[#] Building docker containers\033[0m"
docker compose up --build -d

@echo "\033[0;34m[#] Containers are now running!\033[0m"

stop:
@echo "\033[0;34m[#] Killing old docker processes\033[0m"

docker compose down -t 1

@echo "\033[0;34m[#] Containers are now stopped!\033[0m"
Loading

0 comments on commit 556c3d5

Please sign in to comment.