-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 21b435f
Showing
33 changed files
with
8,169 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: DiploiInitialProjectBuild | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }}-initial-project | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to the GitHub container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: InitialProjectDockerfile | ||
platforms: linux/arm64 | ||
pull: true | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,49 @@ | ||
name: DiploiTemplateBuild | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to the GitHub container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/arm64 | ||
pull: true | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 @@ | ||
node_modules | ||
dist |
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,24 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ | ||
templatesTemp/ |
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,5 @@ | ||
{ | ||
"printWidth": 140, | ||
"trailingComma": "es5", | ||
"singleQuote": 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,5 @@ | ||
{ | ||
"[yaml]": { | ||
"editor.formatOnSave": false | ||
}, | ||
} |
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,6 @@ | ||
apiVersion: v2 | ||
name: diploi-astro | ||
description: Astro is an all-in-one web framework for building fast, content-focused websites. | ||
type: application | ||
version: 1.0.0 | ||
appVersion: 1.16.0 |
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,34 @@ | ||
FROM node:20.9.0-slim | ||
|
||
# This dockerfile is run by diploi image builder, it will have | ||
# this template repository as it's base and the actual project | ||
# repository will be mounted in the repository folder. | ||
|
||
# Update basic packages | ||
RUN apt-get update && apt-get install -y nano supervisor openssh-server git bash wget curl locales libc6 libstdc++6 python-is-python3 ca-certificates tar | ||
|
||
# SSH keys and some login related stuff (some work only for prod) | ||
RUN mkdir -p /run/sshd /root/.ssh \ | ||
&& chmod 0700 /root/.ssh \ | ||
&& ssh-keygen -A \ | ||
&& sed -i s/^#PasswordAuthentication\ yes/PasswordAuthentication\ no/ /etc/ssh/sshd_config \ | ||
&& sed -i s/root:!/"root:*"/g /etc/shadow \ | ||
# Welcome message | ||
&& echo "Welcome to Diploi!" > /etc/motd \ | ||
# Go to app folder by default | ||
&& echo "cd /app;" >> /root/.bashrc | ||
|
||
# Fix LC_ALL: cannot change locale (en_US.UTF-8) error | ||
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \ | ||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \ | ||
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \ | ||
locale-gen en_US.UTF-8 | ||
|
||
# Gitconfig secrets and credential helper | ||
RUN ln -s /etc/diploi-git/gitconfig /etc/gitconfig | ||
COPY diploi-credential-helper /usr/local/bin | ||
|
||
# Init and run supervisor | ||
COPY diploi-runonce.sh /usr/local/bin/diploi-runonce.sh | ||
COPY supervisord.conf /etc/supervisord.conf | ||
CMD /usr/bin/supervisord -c /etc/supervisord.conf |
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 @@ | ||
FROM ghcr.io/diploi/astro-template | ||
|
||
# Install application code | ||
WORKDIR /app | ||
COPY initialProject . | ||
|
||
RUN npm install | ||
RUN npm run 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,27 @@ | ||
A simple starter ToDo app template implemented with Next.js & React. | ||
Includes an optional PostgreSQL database. | ||
|
||
Features full TypeScript support, out-of-the-box DB connection, HMR support, and much more! | ||
|
||
- 💻 [Next.js](https://nextjs.org) | ||
- 💿 [PostgreSQL](https://www.postgresql.org) | ||
|
||
## Next.js | ||
|
||
Available at `/`. | ||
|
||
## PostgreSQL | ||
|
||
Available with a VSCode extension ([SQLTools](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools)) or by CLI. | ||
|
||
### Connect via SQLTools | ||
|
||
1. Open VSCode remote connection to your deployment. | ||
2. Install the [SQLTools](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools) and [SQLTools PostgreSQL/Redshift Driver](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-pg) extensions. | ||
3. Open the "SQLTools" tab in the sidebar and click "Strapi". | ||
|
||
### Connect via CLI | ||
|
||
```bash | ||
su postgres -c 'psql' | ||
``` |
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,32 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Script for continuous updates of github write token for repository | ||
# | ||
|
||
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` Starting $1 >> /var/log/git-credential-helper.log | ||
|
||
# Check that the helper is called with the "get" argument | ||
test "$1" = get || exit 2; | ||
|
||
# Read core token from file | ||
repository=app | ||
ct=`cat /etc/diploi-git/credential-token-$repository` || exit 3; | ||
|
||
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` CredentialToken $ct >> /var/log/git-credential-helper.log | ||
|
||
# Call the core API endpoint with the token | ||
gt=`curl -s -X GET http://core.diploi/git-token/$ct` || exit 4; | ||
|
||
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` AccessToken $gt >> /var/log/git-credential-helper.log | ||
|
||
# Pick the relevant information from the output | ||
username=`echo "$gt" | sed -n '1p'`; | ||
password=`echo "$gt" | sed -n '2p'`; | ||
|
||
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` username=$username >> /var/log/git-credential-helper.log | ||
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` password=$password >> /var/log/git-credential-helper.log | ||
|
||
# Write credentials to helper output | ||
echo "username=$username"; | ||
echo "password=$password"; |
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,56 @@ | ||
#!/bin/sh | ||
|
||
progress() { | ||
current_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
local action="$1" | ||
echo "🟩 $current_date $action" | ||
} | ||
|
||
# Perform tasks at controller pod startup | ||
progress "Runonce started"; | ||
|
||
# Set accepted ssh key(s) | ||
mkdir -p /root/.ssh; | ||
chmod 0700 /root/.ssh; | ||
cat /etc/ssh/internal_ssh_host_rsa.pub > /root/.ssh/authorized_keys; | ||
|
||
cd /app; | ||
|
||
# Seems that this is first run in devel instance | ||
# Intialize persistant storage | ||
if [ ! "$(ls -A /app)" ]; then | ||
|
||
echo "Empty /app, assuming development instance setup was intended"; | ||
|
||
# Make /app default folder | ||
echo "cd /app;" >> /root/.bashrc | ||
|
||
# Generate root ssh key | ||
ssh-keygen -A; | ||
|
||
progress "Pulling code"; | ||
|
||
git init; | ||
git config credential.helper '!diploi-credential-helper'; | ||
git remote add --fetch origin $REPOSITORY_URL; | ||
git checkout -f $REPOSITORY_BRANCH; | ||
git remote set-url origin "$REPOSITORY_URL"; | ||
git config --unset credential.helper; | ||
|
||
progress "Installing"; | ||
npm install; | ||
|
||
fi | ||
|
||
# Update internal ca certificate | ||
update-ca-certificates | ||
|
||
# Make all special env variables available in ssh also (ssh will wipe out env by default) | ||
env >> /etc/environment | ||
|
||
# Now that everything is initialized, start all services | ||
supervisorctl start www | ||
|
||
progress "Runonce done"; | ||
|
||
exit 0; |
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,64 @@ | ||
diploiTemplateVersion: V1.0 | ||
name: diploi-astro | ||
description: Astro is an all-in-one web framework for building fast, content-focused websites. | ||
defaultName: Astro | ||
|
||
stages: | ||
- name: Development | ||
identifier: development | ||
- name: Staging | ||
identifier: staging | ||
- name: Production | ||
identifier: production | ||
|
||
contexts: | ||
- name: app | ||
identifier: app | ||
|
||
repositories: | ||
- name: app | ||
identifier: app | ||
|
||
hosts: | ||
- name: App | ||
identifier: app | ||
urlFormat: '[name].[default-domain]' | ||
|
||
ssh: | ||
- usernameFormat: 'app' | ||
contexts: label=app | ||
stages: | ||
- development | ||
- staging | ||
- usernameFormat: 'app-[index]' | ||
contexts: label=app | ||
stages: | ||
- production | ||
|
||
logs: | ||
- identifier: www-log | ||
name: Astro Log | ||
labelSelector: app=app | ||
command: tail -n 2000 -F /var/log/www.log | ||
|
||
images: | ||
- identifier: app | ||
repository: app | ||
dockerfile: Dockerfile | ||
image: ghcr.io/diploi/astro-template | ||
initialProjectImage: ghcr.io/diploi/astro-template-initial-project | ||
stages: | ||
- development | ||
- production | ||
- staging | ||
manualBuildStages: | ||
- development | ||
|
||
storage: | ||
- identifier: app | ||
stages: | ||
- development | ||
sizeMiB: 6144 | ||
|
||
status: | ||
url: http://app:3000/status |
Oops, something went wrong.