Skip to content

Commit

Permalink
feat: dev container
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Jul 21, 2023
1 parent 922f878 commit cd148d8
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-18-bullseye

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends git-cola

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
RUN su node -c "npm install -g prisma"

RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
73 changes: 73 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "next-boilerplate",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": "docker-compose.yml",

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",
"runServices": ["redis", "db"],

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 5432, 6379, 6080],

"portsAttributes": {
"3000": {
"label": "nextjs"
},
"5432": {
"label": "postgres"
},
"6379": {
"label": "redis"
},
"6080": {
"label": "desktop"
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install && ./scripts/install-brew.sh",

// Configure tool-specific properties.
"customizations": {
"postCreateCommand": "npm install && ./scripts/install-brew.sh",
"vscode": {
"extensions": [
"formulahendry.auto-rename-tag",
"aaron-bond.better-comments",
"WallabyJs.console-ninja",
"EditorConfig.EditorConfig",
"dsznajder.es7-react-js-snippets",
"dbaeumer.vscode-eslint",
"tombonnike.vscode-status-bar-format-toggle",
"github.vscode-github-actions",
"GitHub.copilot",
"GitHub.copilot-chat",
"GitHub.copilot-labs",
"eamodio.gitlens",
"ecmel.vscode-html-css",
"Zignd.html-css-class-completion",
"yzhang.markdown-all-in-one",
"esbenp.prettier-vscode",
"rvest.vs-code-prettier-eslint",
"Prisma.prisma",
"bradlc.vscode-tailwindcss",
"donjayamanne.githistory",
"ms-azuretools.vscode-docker"
]
}
},
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
48 changes: 48 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3.8"

services:
app:
build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:app

redis:
image: redis:latest
restart: unless-stopped
volumes:
- redis-data:/data

# Add "forwardPorts": ["6379"] to **devcontainer.json** to forward Redis locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:app

volumes:
postgres-data:
redis-data:
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
18 changes: 18 additions & 0 deletions .github/workflows/cr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: anc95/ChatGPT-CodeReview@main
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": []
}
7 changes: 7 additions & 0 deletions scripts/install-brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh
sudo chown -R $(whoami) /home/linuxbrew/.linuxbrew
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/$USER/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install gcc
brew install pre-commit
pre-commit install -t commit-msg
11 changes: 11 additions & 0 deletions src/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
8 changes: 8 additions & 0 deletions src/prisma/user.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

0 comments on commit cd148d8

Please sign in to comment.