mirror of
https://github.com/docker/awesome-compose.git
synced 2025-04-19 15:28:06 +02:00
Merge ab6379eff3
into 18f59bdb09
This commit is contained in:
commit
146e2c5c53
3 changed files with 13 additions and 17 deletions
|
@ -8,7 +8,7 @@ redis = Redis(host='redis', port=6379)
|
|||
def hello():
|
||||
redis.incr('hits')
|
||||
counter = str(redis.get('hits'),'utf-8')
|
||||
return "This webpage has been viewed "+counter+" time(s)"
|
||||
return f"This webpage has been viewed {counter} time(s)"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=8000, debug=True)
|
||||
|
|
|
@ -5,15 +5,14 @@ import mysql.connector
|
|||
|
||||
class DBManager:
|
||||
def __init__(self, database='example', host="db", user="root", password_file=None):
|
||||
pf = open(password_file, 'r')
|
||||
self.connection = mysql.connector.connect(
|
||||
user=user,
|
||||
password=pf.read(),
|
||||
host=host, # name of the mysql service as set in the docker compose file
|
||||
database=database,
|
||||
auth_plugin='mysql_native_password'
|
||||
)
|
||||
pf.close()
|
||||
with open(password_file, 'r') as pf:
|
||||
self.connection = mysql.connector.connect(
|
||||
user=user,
|
||||
password=pf.read(),
|
||||
host=host, # name of the mysql service as set in the docker compose file
|
||||
database=database,
|
||||
auth_plugin='mysql_native_password'
|
||||
)
|
||||
self.cursor = self.connection.cursor()
|
||||
|
||||
def populate_db(self):
|
||||
|
@ -24,10 +23,7 @@ class DBManager:
|
|||
|
||||
def query_titles(self):
|
||||
self.cursor.execute('SELECT title FROM blog')
|
||||
rec = []
|
||||
for c in self.cursor:
|
||||
rec.append(c[0])
|
||||
return rec
|
||||
return [c[0] for c in self.cursor]
|
||||
|
||||
|
||||
server = Flask(__name__)
|
||||
|
@ -43,7 +39,7 @@ def listBlog():
|
|||
|
||||
response = ''
|
||||
for c in rec:
|
||||
response = response + '<div> Hello ' + c + '</div>'
|
||||
response = f'{response}<div> Hello {c}</div>'
|
||||
return response
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# syntax=docker/dockerfile:1.4
|
||||
|
||||
FROM --platform=$BUILDPLATFORM maven:3.8.5-eclipse-temurin-17 AS builder
|
||||
FROM --platform=$BUILDPLATFORM maven:3.8.5-eclipse-temurin-17@sha256:a554849fd74b733acb76379bd7df0ea26635a48ab9b54ede1e94bbeaaf448cf6 AS builder
|
||||
WORKDIR /workdir/server
|
||||
COPY pom.xml /workdir/server/pom.xml
|
||||
RUN mvn dependency:go-offline
|
||||
|
@ -29,7 +29,7 @@ RUN mkdir -p target/dependency
|
|||
WORKDIR /workdir/server/target/dependency
|
||||
RUN jar -xf ../*.jar
|
||||
|
||||
FROM eclipse-temurin:17-jre-focal
|
||||
FROM eclipse-temurin:17-jre-focal@sha256:55c1ff40a91898c456dc5a874a66db17b6aa1b4aef8d9cac1ad3b194575638a1
|
||||
|
||||
EXPOSE 8080
|
||||
VOLUME /tmp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue