-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
13c4a1e
commit a0bd253
Showing
15 changed files
with
152 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# comment | ||
|
||
*/temp* | ||
*/*/temp* | ||
temp? | ||
|
||
*.md | ||
!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 @@ | ||
KEY=value |
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 @@ | ||
# escape=\ | ||
|
||
# Use latest python | ||
FROM python | ||
|
||
# Build args | ||
ARG user | ||
ARG buildno=1 | ||
|
||
# Set environment variables | ||
ENV NAME World | ||
ENV WORKDIR /app | ||
|
||
# Set current working directory | ||
WORKDIR ${WORKDIR} | ||
|
||
# Copy all files in current directory on host into container | ||
COPY . /app | ||
|
||
# Install pip packages | ||
RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt | ||
|
||
# Inform others the listening port of service in container | ||
EXPOSE 80 | ||
|
||
# Which command to run when start a container | ||
CMD ["python", "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 @@ | ||
from flask import Flask | ||
from redis import Redis, RedisError | ||
import os | ||
import socket | ||
|
||
redis = Redis(host='redis', socket_connect_timeout=1, socket_timeout=1) | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/") | ||
def hello(): | ||
try: | ||
visits = redis.incr('counter') | ||
except RedisError: | ||
visits = "<i>cannot connect to Redis, counter disabled</i>" | ||
|
||
html = '''<h3>Hello {name}!</h3> | ||
<b>Hostname:</b> {hostname}<br/> | ||
<b>Visits:</b> {visits} | ||
''' | ||
return html.format(name=os.getenv('NAME', 'world'), | ||
hostname=socket.gethostname(), visits=visits) | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0', port=8000) |
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,20 @@ | ||
version: '3' | ||
services: | ||
web: | ||
build: . | ||
image: friendly-web | ||
ports: | ||
- 8001:8000 | ||
networks: | ||
- friendly-net | ||
redis: | ||
image: redis | ||
ports: | ||
- 6380:6379 | ||
volumes: | ||
- ~/data/friendly-hello/redis:/data | ||
command: redis-server --appendonly yes | ||
networks: | ||
- friendly-net | ||
networks: | ||
friendly-net: |
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 @@ | ||
Flask | ||
Redis |
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 @@ | ||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
WORKDIR /root/ | ||
COPY app . | ||
CMD ["./app"] |
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 @@ | ||
FROM golang:1.7.3 | ||
WORKDIR /go/src/github.com/alexellis/href-counter/ | ||
COPY app.go . | ||
RUN go get -d -v golang.org/x/net/html \ | ||
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . |
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,11 @@ | ||
FROM golang:1.7.3 AS builder | ||
WORKDIR /go/src/github.com/alexellis/href-counter/ | ||
RUN go get -d -v golang.org/x/net/html | ||
COPY app.go . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . | ||
|
||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
WORKDIR /root/ | ||
COPY --from=builder /go/src/github.com/alexellis/href-counter/app . | ||
CMD ["./app"] |
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,14 @@ | ||
#!/bin/sh | ||
echo Building alexellis2/href-counter:build | ||
|
||
docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \ | ||
-t alexellis2/href-counter:build . -f Dockerfile.build | ||
|
||
docker container create --name extract alexellis2/href-counter:build | ||
docker container cp extract:/go/src/github.com/alexellis/href-counter/app ./app | ||
docker container rm -f extract | ||
|
||
echo Building alexellis2/href-counter:latest | ||
|
||
docker build --no-cache -t alexellis2/href-counter:latest . | ||
rm ./app |
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
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