Changing README to add Docker description, adding Makefile to build the images, adding buildx support and changing Node implementation to work using more environment values.
This commit is contained in:
parent
eaac691245
commit
f932ff53a6
|
|
@ -0,0 +1,48 @@
|
|||
REPO_OWNER:=NARKOZ
|
||||
PROJECT:=hacker-scripts
|
||||
MULTIARCH:=false
|
||||
ARCHS:=linux/amd64
|
||||
VERSION:=''
|
||||
ALPINE:=false
|
||||
ifeq (true, $(MULTIARCH))
|
||||
ARCHS:=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
|
||||
endif
|
||||
|
||||
all: setup build
|
||||
|
||||
setup:
|
||||
@./buildx.sh
|
||||
|
||||
build: fucking-coffe hangover kumar-asshole smack-my-bitch-up
|
||||
|
||||
fucking-coffe:
|
||||
@docker buildx build \
|
||||
$(ENV) \
|
||||
--file ./nodejs/Dockerfile.fucking_coffe \
|
||||
--platform $(ARCHS) \
|
||||
--push --tag $(REPO_OWNER)/$(PROJECT):fucking-coffe$(VERSION) \
|
||||
../nodejs
|
||||
|
||||
hangover:
|
||||
@docker buildx build \
|
||||
$(ENV) \
|
||||
--file ./nodejs/Dockerfile.hangover \
|
||||
--platform $(ARCHS) \
|
||||
--push --tag $(REPO_OWNER)/$(PROJECT):hangover$(VERSION) \
|
||||
../nodejs
|
||||
|
||||
kumar-asshole:
|
||||
@docker buildx build \
|
||||
$(ENV) \
|
||||
--file ./nodejs/Dockerfile.kumar_asshole \
|
||||
--platform $(ARCHS) \
|
||||
--push --tag $(REPO_OWNER)/$(PROJECT):kumar-asshole$(VERSION) \
|
||||
../nodejs
|
||||
|
||||
smack-my-bitch-up:
|
||||
@docker buildx build \
|
||||
$(ENV) \
|
||||
--file ./nodejs/Dockerfile.smack_my_bitch_up \
|
||||
--platform $(ARCHS) \
|
||||
--push --tag $(REPO_OWNER)/$(PROJECT):smack-my-bitch-up$(VERSION) \
|
||||
../nodejs
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
docker build --platform=local -o . git://github.com/docker/buildx
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
mv buildx ~/.docker/cli-plugins/docker-buildx
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
docker buildx create --name builder --driver docker-container --use
|
||||
|
||||
# https://github.com/docker/docker-ce/blob/master/components/cli/experimental/README.md
|
||||
sudo printf "{\n\
|
||||
\t\"experimental\": true\n\
|
||||
}\n" | sudo tee /etc/docker/daemon.json
|
||||
|
||||
SHELL_RC="/dev/null"
|
||||
|
||||
if [[ "zsh" == ${SHELL} ]]; then
|
||||
SHELL_RC="/.zshrc"
|
||||
fi
|
||||
if [[ "bash" == ${SHELL} ]]; then
|
||||
SHELL_RC="/.bashrc"
|
||||
fi
|
||||
|
||||
printf "\n\
|
||||
# Docker's buildx support\n\
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled\n\
|
||||
export DOCKER_BUILDKIT=1\n\
|
||||
" >> $HOME$SHELL_RC
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
FROM node:lts-alpine3.12
|
||||
LABEL author="fazenda"
|
||||
LABEL project="hacker-scripts:fucking_coffee"
|
||||
|
||||
ENV PORT="3000"
|
||||
ENV CALLBACK_URL="http://xxx.com"
|
||||
ENV CALLBACK_ENDPOINT="coffeemachine"
|
||||
ENV COFFEE_MACHINE_IP="xxx.xxx.xxx.xxx"
|
||||
ENV USERNAME="my_username"
|
||||
ENV PASSWORD="xxxx"
|
||||
|
||||
RUN [ "npm", "install", "express", "telnet-client" ]
|
||||
|
||||
COPY fucking_coffee_yo_server.js .
|
||||
COPY fucking_coffee.js .
|
||||
|
||||
ENTRYPOINT [ "node", "./fucking_coffee_yo_server.js" ]
|
||||
CMD [ "node", "./fucking_coffee" ]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
FROM node:lts-alpine3.12
|
||||
LABEL author="fazenda"
|
||||
LABEL project="hacker-scripts:hangover"
|
||||
|
||||
ENV USERNAME="my_username"
|
||||
ENV TWILIO_ACCOUNT_SID=""
|
||||
ENV TWILIO_AUTH_TOKEN=""
|
||||
|
||||
RUN [ "npm", "install", "twilio" ]
|
||||
|
||||
COPY hangover.js .
|
||||
|
||||
RUN sed -i 's/my_username/${USERNAME}/g' hangover.js
|
||||
|
||||
ENTRYPOINT [ "node", "./hangover.js" ]
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
FROM node:lts-alpine3.12
|
||||
LABEL author="fazenda"
|
||||
LABEL project="hacker-scripts-kumar-asshole"
|
||||
|
||||
ENV KUMAR_EMAIL="kumar.asshole@example.com"
|
||||
ENV GMAIL_USERNAME=""
|
||||
ENV GMAIL_PASSWORD=""
|
||||
|
||||
RUN [ "npm", "install", "nodemailer", "imap" ]
|
||||
|
||||
COPY kumar_asshole.js .
|
||||
|
||||
ENTRYPOINT [ "node", "./kumar_asshole.js" ]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
FROM node:lts-alpine3.12
|
||||
LABEL author="fazenda"
|
||||
LABEL project="hacker-scripts:smack_my_bitch_up"
|
||||
|
||||
ENV MY_NUMBER="+xxx"
|
||||
ENV HER_NUMBER="+xxx"
|
||||
ENV USERNAME="my_username"
|
||||
ENV TWILIO_ACCOUNT_SID=""
|
||||
ENV TWILIO_AUTH_TOKEN=""
|
||||
|
||||
RUN [ "npm", "install", "twilio" ]
|
||||
|
||||
COPY smack_my_bitch_up.js .
|
||||
|
||||
ENTRYPOINT [ "node", "./smack_my_bitch_up.js" ]
|
||||
33
README.md
33
README.md
|
|
@ -42,6 +42,39 @@ GMAIL_PASSWORD=password
|
|||
For Ruby scripts you need to install gems:
|
||||
`gem install dotenv twilio-ruby gmail`
|
||||
|
||||
## Docker
|
||||
|
||||
If you just want to run without having to install any packages, just run the following commands:
|
||||
|
||||
```shell
|
||||
docker run -e ... fazenda/hacker-scripts-{PROJECT}
|
||||
```
|
||||
|
||||
Don't forget to pass the environment variables before with the '-e' in front followed by it, for example:
|
||||
|
||||
```shell
|
||||
docker run -e KUMAR_EMAIL="kumar.asshole@example.com" -e GMAIL_USERNAME="" -e GMAIL_PASSWORD="" fazenda/hacker-scripts-kumar-asshole
|
||||
```
|
||||
|
||||
Each image averages about 30 MB. The values for `PROJECT` being:
|
||||
|
||||
- `fucking-coffe`
|
||||
- `hangover`
|
||||
- `kumar-asshole`
|
||||
- `smack-my-bitch-up`
|
||||
|
||||
And if you want to make your own build, just run the `make` command inside the [Dockerfiles](./Dockerfiles) folder, passing the following arg:
|
||||
|
||||
- REPO_OWNER = `yourDockerHubUsername`
|
||||
- MULTIARCH = `true` / `false` -- to build for the following architectures:
|
||||
- amd64
|
||||
- arm/v6
|
||||
- arm/v7
|
||||
- arm64/v8
|
||||
- ppc64le
|
||||
- s390x
|
||||
- VERSION = Tag value
|
||||
|
||||
## Cron jobs
|
||||
|
||||
```sh
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
var exec = require('child_process').exec;
|
||||
var telnet = require('telnet-client');
|
||||
|
||||
var me = 'my_username';
|
||||
var me = process.env['USERNAME'];
|
||||
|
||||
exec("who", function(error, stdout, stderr) {
|
||||
|
||||
|
|
@ -15,8 +15,8 @@ exec("who", function(error, stdout, stderr) {
|
|||
if(stdout.indexOf(me) == -1)
|
||||
process.exit(/*1*/);
|
||||
|
||||
var coffee_machine_ip = 'xxx.xxx.xxx.xxx';
|
||||
var password = 'xxxx';
|
||||
var coffee_machine_ip = process.env['COFFEE_MACHINE_IP'];
|
||||
var password = process.env['PASSWORD'];
|
||||
var con = new telnet();
|
||||
|
||||
con.on('ready', function(prompt) {
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@
|
|||
var exec = require('child_process').exec;
|
||||
var telnet = require('telnet-client');
|
||||
|
||||
var ME = 'my_username';
|
||||
var ME = process.env['USERNAME'];
|
||||
var AUTHORIZED_YO_NAMES = [ME];
|
||||
var COFFEE_MACHINE_YO_NAME = 'coffeemachine';
|
||||
|
||||
// These should be same as what you set up in the Yo API
|
||||
var CALLBACK_URL = 'http://xxx.com';
|
||||
var CALLBACK_ENDPOINT = '/coffeemachine';
|
||||
var CALLBACK_URL = process.env['CALLBACK_URL'];
|
||||
var CALLBACK_ENDPOINT = '/' + process.env['CALLBACK_ENDPOINT'];
|
||||
|
||||
var PORT = '3000';
|
||||
var PORT = process.env['PORT'];
|
||||
|
||||
exec("who -q", function(error, stdout, stderr) {
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var me = 'my_username';
|
||||
var me = process.env['USERNAME'];
|
||||
|
||||
exec("who -q", function(error, stdout, stderr) {
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ send. Could try implementing with Gmail Node API later.
|
|||
var GMAIL_USERNAME = process.env['GMAIL_USERNAME'];
|
||||
var GMAIL_PASSWORD = process.env['GMAIL_PASSWORD'];
|
||||
|
||||
var KUMAR_EMAIL = 'kumar.asshole@example.com';
|
||||
var KUMAR_EMAIL = process.env['KUMAR_EMAIL'];
|
||||
var EMAIL = 'No worries mate, be careful next time';
|
||||
|
||||
// Scan for unread email from Kumar
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var me = 'my_username';
|
||||
var me = process.env['USERNAME'];
|
||||
|
||||
exec("who -q", function(error, stdout, stderr) {
|
||||
|
||||
|
|
@ -18,8 +18,8 @@ exec("who -q", function(error, stdout, stderr) {
|
|||
var TWILIO_AUTH_TOKEN = process.env['TWILIO_AUTH_TOKEN'];
|
||||
|
||||
// Phone numbers
|
||||
var MY_NUMBER = '+xxx';
|
||||
var HER_NUMBER = '+xxx';
|
||||
var MY_NUMBER = process.env['MY_NUMBER'];
|
||||
var HER_NUMBER = process.env['HER_NUMBER'];
|
||||
|
||||
// Reasons
|
||||
var reasons = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue