-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
173 additions
and
12 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
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 |
---|---|---|
@@ -1,10 +1,27 @@ | ||
.PHONY: dev clean | ||
.PHONY: help | ||
.DEFAULT_GOAL := help | ||
|
||
# create a image "{{project-name}}" with tag "latest" | ||
# based on the Dockerfile in the current directory | ||
dev: | ||
docker image build . -t {{project-name}} | ||
docker container run --rm {{project-name}} | ||
APP_NAME := go | ||
|
||
clean: | ||
docker image rm {{project-name}} | ||
# build image | ||
image: | ||
@docker image build -t $(APP_NAME) . | ||
|
||
# buildx cross | ||
|
||
# Show help | ||
help: | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make [target]" | ||
@echo "" | ||
@echo "Targets:" | ||
@awk '/^[a-zA-Z\-_0-9]+:/ \ | ||
{ \ | ||
helpMessage = match(lastLine, /^# (.*)/); \ | ||
if (helpMessage) { \ | ||
helpCommand = substr($$1, 0, index($$1, ":")-1); \ | ||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ | ||
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ | ||
} \ | ||
} { lastLine = $$0 }' $(MAKEFILE_LIST) |
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,12 @@ | ||
version: Compose specification | ||
|
||
service: | ||
{{project-name}}: | ||
build: . | ||
|
||
networks: | ||
{{project-name}}-net: | ||
name: {{project-name}}-net | ||
ipam: | ||
config: | ||
- subnet: 172.16.238.0/24 |
Empty file.
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,10 @@ | ||
# all start with .(dot), including directories and files | ||
.* | ||
cargo-generate.toml | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
compose.yml | ||
LICENSE* | ||
Makefile | ||
README.md |
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,9 @@ | ||
FROM golang:{{go_version}}-alpine AS builder | ||
|
||
LABEL author="{{authors}}" | ||
|
||
# Set necessary environmet variables needed for our image | ||
ENV GO111MODULE=on | ||
ENV CGO_ENABLED=0 | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 |
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
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,12 @@ | ||
version: Compose specification | ||
|
||
service: | ||
{{project-name}}: | ||
build: . | ||
|
||
networks: | ||
{{project-name}}-net: | ||
name: {{project-name}}-net | ||
ipam: | ||
config: | ||
- subnet: 172.16.238.0/24 |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
# all starts with .(dot), including files and directories | ||
# all start with .(dot), including directories and files | ||
.* | ||
cargo-generate.toml | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
docker-compose.yml | ||
compose.yml | ||
LICENSE* | ||
Makefile | ||
README.md |
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,45 @@ | ||
FROM python:{{py_version}} AS venv | ||
|
||
LABEL author="{{authors}}" | ||
|
||
# set environment variables | ||
# NO Cache | ||
ENV PIP_NO_CACHE_DIR 1 | ||
ENV PIP_INDEX_URL https://pypi.tuna.tsinghua.edu.cn/simple | ||
|
||
WORKDIR /app | ||
|
||
COPY requirement.txt . | ||
|
||
RUN python -m venv venv | ||
|
||
# TODO using pex or not? | ||
RUN . venv/bin/activate && \ | ||
python -m ensurepip -U && \ | ||
pip install -r requirement.txt | ||
|
||
|
||
FROM python:{{py_version}}-slim | ||
|
||
LABEL author="{{authors}}" | ||
|
||
COPY --from=venv /app/venv /app/venv | ||
ENV PATH /app/venv/bin:$PATH | ||
|
||
# set environment variables | ||
# Prevents Python from writing pyc files to disc (equivalent to python -B option) | ||
# https://docs.python.org/3/using/cmdline.html#cmdoption-B | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
# Prevents Python from buffering stdout and stderr (equivalent to python -u option) | ||
# https://docs.python.org/3/using/cmdline.html#cmdoption-u | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
WORKDIR /app | ||
|
||
# if something you want ignore it, add it to .dockerignore | ||
COPY . . | ||
|
||
HEALTHCHECK --start-period=30s CMD python -c "import requests; requests.get('http://localhost:8000', timeout=2)" | ||
|
||
# CMD . .venv/bin/activate && python src/app.py | ||
CMD python src/app.py |
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 @@ | ||
.PHONY: help | ||
.DEFAULT_GOAL := help | ||
|
||
APP_NAME := go | ||
|
||
# build image | ||
image: | ||
@docker image build -t $(APP_NAME) . | ||
|
||
# buildx cross | ||
|
||
# Show help | ||
help: | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make [target]" | ||
@echo "" | ||
@echo "Targets:" | ||
@awk '/^[a-zA-Z\-_0-9]+:/ \ | ||
{ \ | ||
helpMessage = match(lastLine, /^# (.*)/); \ | ||
if (helpMessage) { \ | ||
helpCommand = substr($$1, 0, index($$1, ":")-1); \ | ||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ | ||
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ | ||
} \ | ||
} { lastLine = $$0 }' $(MAKEFILE_LIST) |
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 |
---|---|---|
@@ -1,2 +1,16 @@ | ||
[template] | ||
cargo_generate_version = ">=0.10.0" | ||
|
||
[placeholders.gh_uname] | ||
type = "string" | ||
prompt = "GitHub username (or organization)?" | ||
regex = "^[A-Za-z0-9][A-Za-z0-9-]{0,38}$" | ||
|
||
[placeholders.proj_desc] | ||
type = "string" | ||
prompt = "Project description?" | ||
|
||
[placeholders.py_version] | ||
type = "string" | ||
prompt = "Python version? e.g. 3.8, 3.11" | ||
regex = "^[3-9](\\.[0-9]+){1,2}$" |
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,12 @@ | ||
version: Compose specification | ||
|
||
service: | ||
{{project-name}}: | ||
build: . | ||
|
||
networks: | ||
{{project-name}}-net: | ||
name: {{project-name}}-net | ||
ipam: | ||
config: | ||
- subnet: 172.16.238.0/24 |
Empty file.