Skip to content

Commit 5876098

Browse files
Martín CigorragaMartín Cigorraga
Martín Cigorraga
authored and
Martín Cigorraga
committed
Initial commit of multi-stage Dockerfile
1 parent 767a303 commit 5876098

File tree

6 files changed

+81
-53
lines changed

6 files changed

+81
-53
lines changed

.gitignore

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
.idea/
2-
31
npm-debug.log
42
coverage.out
5-
db.sqlite3
6-
7-
public/vendor/
8-
bindata.go
3+
.vscode
4+
README.html
5+
.DS_Store
6+
*~

Dockerfile

+32-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
1-
FROM golang:latest
2-
MAINTAINER Vladimir Osintsev <[email protected]>
1+
ARG GOLANG_VER=1.12.4-stretch
2+
ARG ALPINE_VER=3.9.3
33

4-
RUN mkdir -p /go/src/app
5-
WORKDIR /go/src/app
4+
## Stage 0: build Go executable from code and templates
5+
FROM golang:${GOLANG_VER} as builder
66

77
COPY . /go/src/app
8+
WORKDIR /go/src/app
89

9-
RUN apt-get update && apt-get -y install --no-install-recommends \
10-
sqlite3 \
11-
nodejs-legacy \
12-
npm && \
13-
apt-get clean && \
14-
rm -rf /var/lib/apt/lists/*
10+
# https://nodesource.com/blog/installing-node-js-tutorial-debian-linux/
11+
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
12+
apt-get -y install --no-install-recommends nodejs && \
13+
npm install -g bower && \
14+
bower --allow-root install && \
15+
mkdir -p /go/src/github.com/cig0 && \
16+
ln -sf /go/src/app /go/src/github.com/cig0/tornote
1517

16-
# Client-side dependencies
17-
RUN npm install -g bower && \
18-
bower --allow-root install
18+
VOLUME /go/src/app/
1919

20-
RUN mkdir -p /go/src/github.com/osminogin && \
21-
ln -sf /go/src/app /go/src/github.com/osminogin/tornote
20+
RUN make install
2221

23-
# Database init with schema
24-
RUN sqlite3 db.sqlite3 <db.scheme
22+
## Stage 1: grab compiled binary
23+
FROM alpine:${ALPINE_VER} as runtime
2524

26-
VOLUME /go/src/app/db.sqlite3
25+
COPY --from=builder /go/bin /go/bin
26+
COPY db.schema /go/src/app/
2727

28-
RUN make install
28+
WORKDIR /go/src/app
29+
ENV PATH="/go/bin:${PATH}"
30+
31+
RUN apk add --update sqlite && \
32+
sqlite3 db.sqlite3 < db.schema && \
33+
adduser -D limited -s /bin/sh && \
34+
chown -R limited.limited /go && \
35+
mkdir /lib64 && \
36+
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
37+
38+
VOLUME /go/src/app/
39+
40+
USER limited
2941

3042
EXPOSE 8080
3143

32-
CMD ["tornote", "-addr", ":8080"]
44+
CMD ["tornote", "-addr", ":8080"]

README.md

+39-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
# Tornote [![Build Status](https://travis-ci.org/osminogin/tornote.svg?branch=master)](https://travis-ci.org/osminogin/tornote) [![Coverage Status](https://coveralls.io/repos/github/osminogin/tornote/badge.svg?branch=master)](https://coveralls.io/github/osminogin/tornote?branch=master)
1+
# Tornote
22

3-
Anonymous self-destructing notes written in Go and with help Stanford Javascript Crypto Library ([SJCL](https://crypto.stanford.edu/sjcl/)) on client-side.
3+
![Screenshot](resources/screenshot.png)
44

5-
Server stores only encrypted data. JavaScript must be enabled, because notes decripted in the Web Browser with key from secret link. After reading encrypted note immediately removed from the database.
5+
[![Build Status](https://travis-ci.org/osminogin/tornote.svg?branch=master)](https://travis-ci.org/osminogin/tornote) [![Coverage Status](https://coveralls.io/repos/github/cig0/tornote/badge.svg?branch=master)](https://coveralls.io/github/cig0/tornote?branch=master)
66

7-
Latest stable version available on https://tornote.org
7+
Anonymous self-destructing notes written in Go with help of Stanford JavaScript Crypto Library ([SJCL](https://crypto.stanford.edu/sjcl/)) on client-side.
88

9-
## Security
10-
11-
How safe Tornote compared with other similar services? More than.
12-
13-
- All private data in the clear text is not leaving the client-side (without encryption).
9+
The server stores only encrypted data. JavaScript must be enabled, because notes are decrypted in the web browser using the key from the secret link. After reading the encrypted note, it is immediately removed from the database.
1410

15-
- Server stored only anonymous encrypted data (without any reference to author or reader).
11+
## Security
1612

17-
- Note decryption executed on the client-side via the SJCL. After reading the encrypted data removed on server.
13+
How safe Tornote is compared with other similar services? More than many of them.
1814

19-
If you have ideas to improve the our safety/security so far as possible please post the issue.
15+
+ All private data in clear text doesn't leave the client-side without being encrypted first
16+
+ Server stores only anonymous encrypted data, without any reference to it's author or reader
17+
+ Note decryption is executed on the client-side via the SJCL. After reading the encrypted note, it's data is removed from the server
2018

21-
## Getting started
22-
23-
```bash
24-
$ go get -u github.com/osminogin/tornote
25-
$ cd $GOPATH/src/github.com/osminogin/tornote
26-
$ bower install
27-
$ make install
28-
$ tornote &
29-
```
19+
If you have ideas to improve safety/security please open a new issue.
3020

3121
## Running with Docker
3222

@@ -38,3 +28,31 @@ $ docker run -p 80:8080 --name tornote tornote-app
3828
## License
3929

4030
AGPLv3 or later
31+
32+
----
33+
34+
### TO DO (in no particular order)
35+
36+
```diff
37+
+ [ DONE ] Move away from any 'latest' declaration for packages versions
38+
+ [ DONE ] Migrate from golang:1.12.4-stretch to a smaller base
39+
+ [ DONE ] Added package.json for future migration from Bower to Yarn
40+
+ [ DONE ] Tornote is now running as a limited user (instead of as root) for enhanced security
41+
+ [ DONE ] Create a multi-stage Dockerfile
42+
- Migrate from Bower to Yarn
43+
- Fix testing & badges
44+
```
45+
46+
### Repo notice
47+
48+
#### Branches description
49+
50+
+ **master**: production-ready branch; this is the branch that should be pulled when running this app in production
51+
+ **stage**: a.k.a. release branch
52+
+ **dev**: development branch; all work branches have to be merged here
53+
54+
#### How to contribute
55+
56+
Fork the repo and PR against `dev` branch.
57+
58+
All credits goes to the original author, thank you [Vladimir Osintsev](https://github.com/osminogin) for sharing!

resources/screenshot.png

422 KB
Loading

templates/layout/base.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<nav class="navbar navbar-default navbar-fixed-top">
2424
<div class="container">
2525
<div class="navbar-header">
26-
<a class="navbar-brand" href="/">tornote<span class="text-muted">.org</span></a>
26+
<a class="navbar-brand" href="/">tornote<span class="text-muted">| Anonymous self-destructing notes</span></a>
2727
</div>
2828
</div>
2929
</nav>
@@ -36,10 +36,10 @@
3636
<!-- Footer -->
3737
<footer class="footer">
3838
<div class="container">
39-
<p class="text-muted">
40-
Tornote is open source software licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPLv3</a>.
41-
Source code available on <a href="https://github.com/osminogin/tornote">GitHub</a>
42-
<span class="glyphicon glyphicon-link small"></span>.
39+
<p class="text-muted" align="center">
40+
Tornote is open source software licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPLv3</a>
41+
Source code available on <a href="https://github.com/cig0/tornote">GitHub</a>
42+
<span class="glyphicon glyphicon-link small"></span>
4343
</p>
4444
</div>
4545
</footer>

tornote/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"log"
2323
"os"
2424

25-
"github.com/osminogin/tornote"
25+
"github.com/cig0/tornote"
2626
)
2727

2828
var (

0 commit comments

Comments
 (0)