Skip to content

Commit

Permalink
Add sample apps for nodejs esm, flask, php
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingrobot committed Feb 1, 2024
1 parent 7ee9805 commit 6fa50d5
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ jobs:
- type: aspnetcore
dockerfile: "src/aspnetcore/Dockerfile"
context: "src/aspnetcore"
- type: fastify-esm
dockerfile: "src/fastify-esm/Dockerfile"
context: "src/fastify-esm"
- type: flask
dockerfile: "src/flask/Dockerfile"
context: "src/flask"
- type: php
dockerfile: "src/php/Dockerfile"
context: "src/php"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 12 additions & 0 deletions src/fastify-esm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:20

WORKDIR /app

COPY package.json /app
RUN npm install

COPY server.js /app

EXPOSE 3000

CMD ["node", "server"]
6 changes: 6 additions & 0 deletions src/fastify-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "module",
"dependencies": {
"fastify": "^4.26.0"
}
}
19 changes: 19 additions & 0 deletions src/fastify-esm/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Fastify from 'fastify'
const fastify = Fastify({
logger: true
})

// Declare a route
fastify.get('/', async function handler(request, reply) {
reply.code(200)
.type('text/html')
.send("Hello World!")
})

// Run the server!
try {
await fastify.listen({ port: 3000, host: "0.0.0.0" })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
16 changes: 16 additions & 0 deletions src/flask/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

FROM --platform=$BUILDPLATFORM python:3-slim

WORKDIR /app

COPY requirements.txt /app
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install -r requirements.txt

COPY app.py /app

EXPOSE 8000

ENTRYPOINT ["python3"]
CMD ["app.py"]

9 changes: 9 additions & 0 deletions src/flask/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
return "Hello World!"

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
1 change: 1 addition & 0 deletions src/flask/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flask
4 changes: 4 additions & 0 deletions src/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

FROM php:8.2-apache
COPY index.php /var/www/html/

3 changes: 3 additions & 0 deletions src/php/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
phpinfo();
?>

0 comments on commit 6fa50d5

Please sign in to comment.