Skip to content

Commit 1a26cd7

Browse files
add gatsby, move to examples
1 parent 82bad87 commit 1a26cd7

32 files changed

+14149
-2
lines changed

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "node"]
2-
path = node
2+
path = examples/node
33
url = https://github.com/pythoninthegrass/node_with_docker.git
4+
[submodule "gatsby"]
5+
path = examples/gatsby
6+
url = https://github.com/pythoninthegrass/gatsby_docker.git

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ repos:
4848
exclude: |
4949
(?x)^(
5050
.vscode/launch.json|
51-
.vscode/settings.json
51+
.vscode/settings.json|
52+
examples/gatsby/tsconfig.json|
53+
examples/node/tsconfig.json|
54+
examples/gatsby/package.json|
55+
examples/node/package.json
5256
)$
5357
args: ['--autofix', '--indent=2', '--no-sort-keys']
5458
- id: requirements-txt-fixer

examples/django/.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**/__pycache__
2+
**/.classpath
3+
**/.dockerignore
4+
**/.DS_Store
5+
**/.editorconfig
6+
**/.env
7+
**/.git
8+
**/.github
9+
**/.gitignore
10+
**/.project
11+
**/.settings
12+
**/.toolstarget
13+
**/.vs
14+
**/.vscode
15+
**/*.*proj.user
16+
**/*.dbmdl
17+
**/*.jfm
18+
**/*.py#
19+
**/*.py~
20+
**/*.pyc
21+
**/azds.yaml
22+
**/bin
23+
**/charts
24+
**/compose*
25+
**/csv
26+
**/django
27+
**/docker-compose*
28+
**/Dockerfile*
29+
**/img
30+
**/node_modules
31+
**/npm-debug.log
32+
**/obj
33+
**/README.md
34+
**/secrets.dev.yaml
35+
**/terraform
36+
**/values.dev.yaml

examples/django/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# syntax=docker/dockerfile:1
2+
FROM python:3
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
WORKDIR /code
6+
COPY requirements.txt /code/
7+
RUN pip install -r requirements.txt
8+
COPY . /code/

examples/django/compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# compose.yml
2+
version: "3.9"
3+
4+
services:
5+
db:
6+
image: postgres
7+
volumes:
8+
- ./data/db:/var/lib/postgresql/data
9+
environment:
10+
- POSTGRES_NAME=postgres
11+
- POSTGRES_USER=postgres
12+
- POSTGRES_PASSWORD=postgres
13+
web:
14+
build: .
15+
command: python manage.py runserver 0.0.0.0:8000
16+
volumes:
17+
- .:/code
18+
ports:
19+
- "8000:8000"
20+
environment:
21+
- POSTGRES_NAME=postgres
22+
- POSTGRES_USER=postgres
23+
- POSTGRES_PASSWORD=postgres
24+
depends_on:
25+
- db

examples/gatsby/.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.git
2+
node_modules
3+
.eslint*
4+
.prettier*
5+
.git*
6+
.vscode
7+
README.md
8+
Dockerfile*
9+
docker-compose.yml
10+
public
11+
.cache

examples/gatsby/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
.cache/
3+
.vscode
4+
my-gatsby-site/
5+
public
6+
scratch.*
7+
src/gatsby-types.d.ts
8+
yarn-error.log

examples/gatsby/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM python:3.11-bullseye AS build
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN <<EOF
6+
#!/usr/bin/env bash
7+
set -euxo pipefail
8+
9+
# install nodejs 18 and yarn
10+
curl -sL https://deb.nodesource.com/setup_18.x | bash -
11+
apt update
12+
apt upgrade -y
13+
apt install -y \
14+
nodejs \
15+
&& npm install -g yarn \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
EOF
19+
20+
WORKDIR /usr/src/app
21+
22+
COPY . .
23+
24+
RUN <<EOF
25+
#!/usr/bin/env bash
26+
set -euxo pipefail
27+
28+
# install dependencies
29+
yarn
30+
31+
# disable telemetry
32+
yarn global add gatsby-cli && gatsby telemetry --disable
33+
34+
# TODO: npx update-browserslist-db@latest
35+
36+
# build
37+
yarn build
38+
39+
EOF
40+
41+
# * QA-only
42+
# CMD [ "sleep", "infinity" ]
43+
# CMD [ "bash", "-c", "sleep infinity" ]
44+
45+
FROM node:18-bullseye-slim AS server
46+
47+
WORKDIR /usr/src/app
48+
COPY --from=build /usr/src/app/public .
49+
COPY --from=build /usr/src/app/node_modules ./node_modules
50+
51+
EXPOSE 8000

examples/gatsby/Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.DEFAULT_GOAL := help
2+
.ONESHELL:
3+
export SHELL := $(shell which bash)
4+
# .SHELLFLAGS := -eu -o pipefail -c
5+
# MAKEFLAGS += --warn-undefined-variables
6+
7+
# ENV VARS
8+
export UNAME := $(shell uname -s)
9+
10+
# colors
11+
GREEN := $(shell tput -Txterm setaf 2)
12+
YELLOW := $(shell tput -Txterm setaf 3)
13+
WHITE := $(shell tput -Txterm setaf 7)
14+
CYAN := $(shell tput -Txterm setaf 6)
15+
RESET := $(shell tput -Txterm sgr0)
16+
17+
# targets
18+
.PHONY: all
19+
all: init dev open help
20+
21+
init: ## create a new gatsby site using the minimal typescript starter
22+
[[ ! -d "my-gatsby-site" ]] && npm init gatsby || echo "my-gatsby-site already exists"
23+
24+
dev: init ## start the site in development mode
25+
cd my-gatsby-site; \
26+
yarn develop
27+
28+
# TODO: QA
29+
open: ## open the site in your browser
30+
@echo "Opening http://localhost:8000"
31+
num_fields(): ps aux | grep -E "node.*yarn develop" | grep -v grep | awk '{print NF}'); \
32+
get_field(): expr $$num_fields - 1); \
33+
sec_to_last=$(get_field); \
34+
check_proc(): ps aux | grep -E "node.*yarn develop" | grep -v grep | awk '{print $'$sec_to_last', $NF}'); \
35+
ret_code=$$?; \
36+
while [ $$ret_code -ne 0 ]; do \
37+
sleep 10; \
38+
check_proc(); \
39+
ret_code=$$?; \
40+
done; \
41+
if [ "$(UNAME)" = "Darwin" ]; then \
42+
open http://localhost:8000; \
43+
elif [ "$(UNAME)" = "Linux" ]; then \
44+
xdg-open http://localhost:8000; \
45+
fi
46+
47+
all: init dev open ## run all targets
48+
49+
help: ## show this help
50+
@echo ''
51+
@echo 'Usage:'
52+
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
53+
@echo ''
54+
@echo 'Targets:'
55+
@awk 'BEGIN {FS = ":.*?## "} { \
56+
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
57+
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
58+
}' $(MAKEFILE_LIST)

examples/gatsby/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<p align="center">
2+
<a href="https://www.gatsbyjs.com/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts">
3+
<img alt="Gatsby" src="https://www.gatsbyjs.com/Gatsby-Monogram.svg" width="60" />
4+
</a>
5+
</p>
6+
<h1 align="center">
7+
Gatsby minimal TypeScript starter
8+
</h1>
9+
10+
## 🚀 Quick start
11+
12+
1. **Create a Gatsby site.**
13+
14+
Use the Gatsby CLI to create a new site, specifying the minimal TypeScript starter.
15+
16+
```shell
17+
# create a new Gatsby site using the minimal TypeScript starter
18+
npm init gatsby
19+
```
20+
21+
2. **Start developing.**
22+
23+
Navigate into your new site’s directory and start it up.
24+
25+
```shell
26+
cd my-gatsby-site/
27+
npm run develop
28+
```
29+
30+
3. **Open the code and start customizing!**
31+
32+
Your site is now running at http://localhost:8000!
33+
34+
Edit `src/pages/index.tsx` to see your site update in real-time!
35+
36+
4. **Learn more**
37+
38+
- [Documentation](https://www.gatsbyjs.com/docs/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
39+
40+
- [Tutorials](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
41+
42+
- [Guides](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
43+
44+
- [API Reference](https://www.gatsbyjs.com/docs/api-reference/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
45+
46+
- [Plugin Library](https://www.gatsbyjs.com/plugins?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
47+
48+
- [Cheat Sheet](https://www.gatsbyjs.com/docs/cheat-sheet/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
49+
50+
## 🚀 Quick start (Gatsby Cloud)
51+
52+
Deploy this starter with one click on [Gatsby Cloud](https://www.gatsbyjs.com/cloud/):
53+
54+
[<img src="https://www.gatsbyjs.com/deploynow.svg" alt="Deploy to Gatsby Cloud">](https://www.gatsbyjs.com/dashboard/deploynow?url=https://github.com/gatsbyjs/gatsby-starter-minimal-ts)

0 commit comments

Comments
 (0)