Skip to content

Commit

Permalink
Add docker deployment examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspanni committed Jun 14, 2024
1 parent 848b640 commit 63945a9
Show file tree
Hide file tree
Showing 17 changed files with 1,039 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 14_Deployment_Docker/Nginx-Static/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:alpine

COPY static /usr/share/nginx/html
12 changes: 12 additions & 0 deletions 14_Deployment_Docker/Nginx-Static/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Static HTML</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>Static HTML</h1>
<p>This is a static HTML page.</p>
</body>
</html>
1 change: 1 addition & 0 deletions 14_Deployment_Docker/Nginx-Static/static/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert("Script works!");
6 changes: 6 additions & 0 deletions 14_Deployment_Docker/Nginx-Static/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
font-size: 2em;
font-family: Arial, sans-serif;
color: #ffffff;
background-color: #333;
}
15 changes: 15 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
175 changes: 175 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
13 changes: 13 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM oven/bun as build

COPY package.json bun.lockb /
RUN bun install --frozen-lockfile


FROM oven/bun as app
WORKDIR /app

COPY --from=build node_modules node_modules
COPY package.json src /app/

CMD ["bun", "run", "."]
15 changes: 15 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# rest-api-bun

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file added 14_Deployment_Docker/REST-API-Bun/bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "rest-api-bun",
"module": "src/index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest",
"@types/express": "^4.17.21"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"express": "^4.19.2"
}
}
19 changes: 19 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2024 Lukas Panni
import express from "express";

type User = { id: number; name: string };

const users: Array<User> = [
{ id: 1, name: "Max" },
{ id: 2, name: "Moritz" },
];

const app = express();
app.get("/users", (request, response) => {
response.send(users);
});

app.listen(80, () => {
console.log("Server gestartet");
});
22 changes: 22 additions & 0 deletions 14_Deployment_Docker/REST-API-Bun/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

/* Linting */
"skipLibCheck": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true
}
}
5 changes: 5 additions & 0 deletions 14_Deployment_Docker/REST-API-Node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:lts

COPY . /app
WORKDIR /app
CMD ["node", "src/index.js"]
12 changes: 12 additions & 0 deletions 14_Deployment_Docker/REST-API-Node/multistage.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:lts AS build

COPY package*.json .
RUN npm ci --only=production

FROM node:lts AS app

WORKDIR /app
COPY --from=build node_modules node_modules
COPY package.json src /app/

CMD ["node", "index.js"]
Loading

0 comments on commit 63945a9

Please sign in to comment.