Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #48

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Stoken
# # To refresh tokens:
# # Backup old stokenrc
# `cp ~/.stokenrc ~/.stokenrc.bak; rm ~/.stokenrc`
# # Import new token & remember not to enter a password at prompt
# `docker run -it -v /Users/smcquaid:/root stevemcquaid/stoken:latest stoken import --file=/root/.stoken/smcquaid_000700590089.sdtid`
# # If you do enter a password in previous step, unset it with this command
# `docker run -it -v /Users/smcquaid:/root stevemcquaid/stoken:latest stoken setpass`
# # Then run `stoken` to test
stoken() {
docker run -it -v /Users/smcquaid:/root stevemcquaid/stoken:latest stoken
}
26 changes: 26 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:16.04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These large tabs should be reduced to a single space, I have never seen a Dockerfile formatted this way.


RUN apt-get update
RUN apt-get install -y \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be combined into a single command with &&.

Also clean the apt cache after installing packages. See the apt-get recommendations here.

libgtk-3-dev \
libtomcrypt-dev \
libxml2-dev \
libtomcrypt-dev \
autoconf \
automake \
libtool \
build-essential \
git

RUN git clone git://github.com/cernekee/stoken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https:// instead of git://?


WORKDIR stoken

RUN bash autogen.sh && \
./configure && \
make && \
make check && \
make install && \
ldconfig

CMD stoken
26 changes: 26 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Build container
build:
@bash -x scripts/build.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If build.sh is a one-liner, just inline it here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was kind of wondering if it is more common for Docker users to invoke make -C docker build, ./docker/scripts/build.sh, or something else.

For make -C docker run I would assume you'll want a way to pass arguments, so that the user can at least perform basic operations like importing a new token?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I think it's more common for Docker users to run docker commands themselves. If I saw a Dockerfile in a project, it would be logical that I can simply do

docker build -t mytagname dir
docker run -it mytagname bash

I'm not sure these make targets or helper scripts provide much value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short, as a first step, I would probably just commit docker/Dockerfile and leave it at that. Most Docker users and tools know what to do with that.


## Push container
push:
@bash -x scripts/push.sh

## Run project
run:
@bash -x scripts/run.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just inline the command here.


help:
@printf "Available targets:\n\n"
@awk '/^[a-zA-Z\-\_0-9%:\\]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = $$1; \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub("\\\\", "", helpCommand); \
gsub(":+$$", "", helpCommand); \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u
@printf "\n"
4 changes: 4 additions & 0 deletions docker/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -ex

docker build -t stevemcquaid/stoken:latest .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously without your user name hard coded here.

4 changes: 4 additions & 0 deletions docker/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker run -it -v $HOME:/root stevemcquaid/stoken:latest stoken $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same user name issue here.