-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 2338202
Showing
11 changed files
with
519 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Release exec_bash_exercise | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'exec_bash_exercise_and_first_volume_exercise/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
env: | ||
SECRET_MESSAGE: ${{ secrets.EXEC_BASH_EXERCISE_SECRET_MESSAGE }} | ||
with: | ||
name: jakousa/exec_bash_exercise | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
tags: latest | ||
buildargs: SECRET_MESSAGE | ||
context: exec_bash_exercise_and_first_volume_exercise |
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,26 @@ | ||
name: Release first_volume_exercise | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'exec_bash_exercise_and_first_volume_exercise/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
env: | ||
SECRET_MESSAGE: ${{ secrets.FIRST_VOLUME_EXERCISE_SECRET_MESSAGE }} | ||
with: | ||
name: jakousa/first_volume_exercise | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
tags: latest | ||
buildargs: SECRET_MESSAGE | ||
context: exec_bash_exercise_and_first_volume_exercise |
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,23 @@ | ||
name: Release ports_exercise | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'ports_exercise/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
with: | ||
name: jakousa/ports_exercise | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
tags: latest | ||
context: ports_exercise |
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 node:dubnium | ||
|
||
ARG SECRET_MESSAGE | ||
ENV SECRET_MESSAGE=$SECRET_MESSAGE | ||
|
||
WORKDIR /usr/app | ||
COPY . . | ||
|
||
CMD ["node", "index"] |
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 @@ | ||
Writes "secret message" to file every 15 seconds. Otherwise logs time. |
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,42 @@ | ||
const fsPromises = require('fs').promises | ||
|
||
const SECRET_MESSAGE = process.env.SECRET_MESSAGE | ||
const filePath = `${__dirname}/logs.txt` | ||
let rounds = 0 | ||
let filehandle | ||
|
||
const printTimeToFile = async () => { | ||
const startTime = new Date().getTime() | ||
if (filehandle === undefined) { | ||
try { | ||
filehandle = await fsPromises.open(filePath, 'w') | ||
} catch (err) { | ||
console.error('Failed to open file', filePath, err) | ||
return | ||
} | ||
} | ||
rounds++ | ||
const GMTString = new Date().toGMTString() | ||
const writeString = (rounds % 5 === 0) ? `Secret message is:\n"${SECRET_MESSAGE}"` : GMTString | ||
try { | ||
await filehandle.appendFile(`${writeString}\n`) | ||
console.log(`Wrote to file ${filePath}`) | ||
} catch (err) { | ||
console.error('Failed to write to file', err) | ||
} | ||
|
||
const timeNow = new Date().getTime() | ||
setTimeout(printTimeToFile, 3000 - (timeNow - startTime)) | ||
} | ||
|
||
printTimeToFile() | ||
|
||
const gracefulClose = async () => { | ||
if (filehandle !== undefined) console.log('Closing file') && await filehandle.close() | ||
process.exit(0) | ||
} | ||
|
||
process.on('SIGTERM', gracefulClose) | ||
process.on('SIGINT', gracefulClose) | ||
|
||
|
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,9 @@ | ||
FROM node:alpine | ||
|
||
WORKDIR /usr/app | ||
|
||
COPY package* ./ | ||
RUN npm ci | ||
COPY . . | ||
|
||
CMD ["npm", "start"] |
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 @@ | ||
const express = require("express") | ||
|
||
const app = express() | ||
|
||
const PORT = 80 | ||
|
||
app.get('*', (req, res) => res.send('Ports configured correctly!!').end()) | ||
|
||
app.listen(PORT, () => | ||
console.log(`Listening on port ${PORT}, this means inside of the container. Use -p to map the port to a port of your local machine.`)) |
Oops, something went wrong.