Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed May 1, 2024
1 parent e6eebff commit 82959f5
Show file tree
Hide file tree
Showing 28 changed files with 3,411 additions and 50 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/ansible/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Install Requirements
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Install roles from Ansible Galaxy
command: ansible-galaxy install {{ item }}
with_items:
- "geerlingguy.docker"
2 changes: 2 additions & 0 deletions .devcontainer/ansible/roles/setup-container/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dotfiles_url: "{{ lookup('env', 'DOTFILES_URL') }}"
dotfiles_path: "{{ lookup('env', 'HOME') + '/.dotfiles' }}"
2 changes: 2 additions & 0 deletions .devcontainer/ansible/roles/setup-container/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- { role: geerlingguy.docker, become: true }
13 changes: 13 additions & 0 deletions .devcontainer/ansible/roles/setup-container/tasks/dotfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: Clone/Update git repo {{ dotfiles_url }} to {{ dotfiles_path }}
git:
repo: "{{ dotfiles_url }}"
dest: "{{ dotfiles_path }}"
recursive: yes # Recursively clone submodules
update: yes
force: yes
accept_hostkey: yes
ignore_errors: yes

- name: Execute {{ dotfiles_path }}/install
command: "{{ dotfiles_path }}/install"
ignore_errors: yes
2 changes: 2 additions & 0 deletions .devcontainer/ansible/roles/setup-container/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- include_tasks: ssh.yml
- include_tasks: dotfiles.yml
22 changes: 22 additions & 0 deletions .devcontainer/ansible/roles/setup-container/tasks/ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: et permissions on ~/.ssh
file:
path: "{{ lookup('env', 'HOME') + '/.ssh' }}"
state: directory
owner: "{{ lookup('env', 'USER') }}"
group: "{{ lookup('env', 'USER') }}"
recurse: true
mode: '0700'

- name: Set permissions for ~/.ssh files
file:
path: "{{ item }}"
mode: '0600'
owner: "{{ lookup('env', 'USER') }}"
group: "{{ lookup('env', 'USER') }}"
with_fileglob:
- "{{ lookup('env', 'HOME') }}/.ssh/*"

- name: Setup and start ssh-agent
shell: |
ssh-add
eval "$(ssh-agent)"
18 changes: 18 additions & 0 deletions .devcontainer/ansible/setup-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Setup container
hosts: localhost
connection: local
gather_facts: true
vars:
# docker defaults
docker_edition: 'ce'
docker_package_state: present
docker_service_manage: false
docker_install_compose_plugin: true
docker_compose_package: docker-compose-plugin
docker_compose_package_state: present

docker_users:
- "{{ lookup('env', 'USER') }}"
roles:
- role: setup-container
65 changes: 65 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "${localWorkspaceFolderBasename}",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"containerEnv": {
"HOST_PROJECT_PATH": "${localWorkspaceFolder}",
"PROJECT_NAME": "${localWorkspaceFolderBasename}",
"PROJECT_PATH": "${containerWorkspaceFolder}",
"FLASK_DEBUG": "True",
"ANSIBLE_LOCALHOST_WARNING": "False",
"ANSIBLE_INVENTORY_UNPARSED_WARNING": "False"
},
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": {
"context": "..",
"dockerfile": "../Dockerfile",
"target": "devcontainer",
"args": {
"PROJECT_NAME": "${localWorkspaceFolderBasename}",
"PROJECT_PATH": "${containerWorkspaceFolder}"
}
},
"initializeCommand": "touch ${localWorkspaceFolder}/.devcontainer/.env",
"updateContentCommand": "make ansible",
"runArgs": ["--name","${localWorkspaceFolderBasename}_devcontainer", "--hostname","${localWorkspaceFolderBasename}", "--env-file",".devcontainer/.env", "--gpus","all"],
"mounts": [
"source=${localWorkspaceFolderBasename}-home,target=/home/anvil,type=volume",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/anvil/.ssh,type=bind,consistency=cached",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],

//Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"jeff-hykin.better-dockerfile-syntax",
"ms-vsliveshare.vsliveshare",
"mikestead.dotenv",
"EditorConfig.EditorConfig",
"redhat.vscode-yaml",
"codeium.codeium",
"ms-toolsai.jupyter",
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"nhoizey.gremlins",
"esbenp.prettier-vscode",
"peakchen90.open-html-in-browser"
],
"settings": {
"files.exclude": {
"**/__pycache__": true,
"**/.webassets-cache": true,
"**/*.pyc": {
"when": "$(basename).py"
}
},
"dev.containers.copyGitConfig": false,
"dev.containers.gitCredentialHelperConfigLocation": "system",
"files.readonlyFromPermissions": true,
"python.analysis.extraPaths": [ "${containerWorkspaceFolder}/app" ],
}
}
}
}
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/feed_cache
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
106 changes: 106 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# name: Build and Publish Docker Image

# # This workflow uses actions that are not certified by GitHub.
# # They are provided by a third-party and are governed by
# # separate terms of service, privacy policy, and support
# # documentation.

# on:
# workflow_dispatch:
# push:
# branches: [ "main" ]
# # Publish semver tags as releases.
# tags: [ 'v*.*.*' ]
# paths:
# - 'app/**/*'
# - 'Dockerfile'
# - 'requirements.txt'
# - '.github/workflows/docker-publish.yml'
# pull_request:
# branches: [ "main" ]
# types: [ closed ]
# paths:
# - 'app/**/*'
# - 'Dockerfile'
# - 'requirements.txt'
# - '.github/workflows/docker-publish.yml'

# env:
# # Use docker.io for Docker Hub if empty
# REGISTRY: ghcr.io
# # github.repository as <account>/<repo>
# IMAGE_NAME: ${{ github.repository }}


# jobs:
# build:

# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# # This is used to complete the identity challenge
# # with sigstore/fulcio when running outside of PRs.
# id-token: write

# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# # Set up BuildKit Docker container builder to be able to build
# # multi-platform images and export cache
# # https://github.com/docker/setup-buildx-action
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# # Login against a Docker registry except on PR
# # https://github.com/docker/login-action
# - name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
# uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v5
# with:
# # list of Docker images to use as base name for tags
# images: |
# ghcr.io/${{ github.repository }}
# # generate Docker tags based on the following events/attributes
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=raw,value=latest,enable={{is_default_branch}}
# type=sha

# # Build and push Docker image with Buildx (don't push on PR)
# # https://github.com/docker/build-push-action
# - name: Build and push Docker image
# id: build-and-push
# uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
# with:
# context: .
# target: production
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max

# - name: Discord notification
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# uses: rjstone/discord-webhook-notify@v1
# with:
# severity: info
# username: MafenBot
# color: '#ff00aa'
# avatarUrl: https://github.githubassets.com/images/modules/logos_page/Octocat.png
# description: A new ${{ github.event.repository.name }} image ${{ steps.meta.outputs.tags }} has been published
# details: Based on ${{ github.event.head_commit.url }}
# footer: MafenBot became self aware
# webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
54 changes: 4 additions & 50 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@

app/assets


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand All @@ -51,10 +32,6 @@ coverage.xml
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
Expand All @@ -65,11 +42,6 @@ db.sqlite3-journal
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
Expand Down Expand Up @@ -116,8 +88,6 @@ __pypackages__/
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
Expand All @@ -128,13 +98,6 @@ ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

Expand All @@ -149,12 +112,3 @@ dmypy.json
# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python Debugger: Flask",
"type": "debugpy",
"request": "launch",
"module": "flask",
"envFile": "${workspaceFolder}/.devcontainer/.env",
"env": {
"FLASK_APP": "app/app.py",
"FLASK_DEBUG": "True",
"FLASK_RUN_PORT": "9830",
"FLASK_ENV": "development"
},
"args": [
"run",
"--debug"
],
"jinja": true,
"autoStartBrowser": false
}
]
}
Loading

0 comments on commit 82959f5

Please sign in to comment.