Skip to content

Commit

Permalink
add Dockerfile
Browse files Browse the repository at this point in the history
increase version
  • Loading branch information
radumarias committed Apr 21, 2024
1 parent 3ae4f11 commit 8a7531f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "encryptedfs"
description = "An encrypted file system that mounts with FUSE on Linux. It can be used to create encrypted directories."
version = "0.1.22"
version = "0.1.23"
edition = "2021"
license = "Apache-2.0"
authors = ["Radu Marias <[email protected]>"]
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
################
##### Builder
FROM alpine:3.16.0 as builder

RUN apk add binutils build-base ca-certificates curl file g++ gcc libressl-dev make patch postgresql rust

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

RUN . ~/.cargo/env && rustup target add x86_64-unknown-linux-musl

# Cache downloaded+built dependencies
COPY Cargo.toml Cargo.lock /usr/src/encryptedfs/
RUN mkdir /usr/src/encryptedfs/src && \
echo 'fn main() {}' > /usr/src/encryptedfs/src/main.rs

RUN . ~/.cargo/env && cd /usr/src/encryptedfs/ && cargo build --release && \
rm -Rvf /usr/src/encryptedfs/src

# Build our actual code
COPY src /usr/src/encryptedfs/src
RUN touch /usr/src/encryptedfs/src/main.rs
RUN . ~/.cargo/env && \
cd /usr/src/encryptedfs/ && \
cargo build --target x86_64-unknown-linux-musl --release

################
##### Runtime
FROM alpine:3.16.0 AS runtime

RUN apk add fuse3

# Copy application binary from builder image
COPY --from=builder /usr/src/encryptedfs/target/x86_64-unknown-linux-musl/release/encryptedfs /usr/local/bin

# Run the application
CMD ["encryptedfs", "--help"]
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ cargo install encryptedfs
```

To use the encrypted file system, you need to have FUSE installed on your system. You can install it by running the following command (or based on your distribution):

Arch
```bash
sudo pacman -Syu && sudo pacman -S fuse3
```
Ubuntu
```bash
sudo apt-get update
sudo apt-get -y install fuse3
sudo apt-get update && sudo apt-get -y install fuse3
```

A basic example of how to use the encrypted file system is shown below:

```
Expand Down Expand Up @@ -76,3 +82,38 @@ You can specify the log level adding the `--log-level` argument to the command l
```bash
--log-level LEVEL
```

## Start it in docker
```bash
docker pull xorio42/encryptedfs
```
Start a container to set up mount in it

`docker run -it --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined xorio42/encryptedfs:latest /bin/sh`

In the container create mount and data directories

`mkdir fsmnt && mkdir fsdata`

Start `encryptedfs`

`encryptedfs --mount-point fsmnt --data-dir fsdata`

Enter a password for encryption.

Get the container ID

`docker ps`

In another terminal attach to running container with the above ID

`docker exec -it <ID> /bin/sh`

From here you can play with it by creating files in `fsmnt` directory
```
cd fsmnt
mkdir 1
ls
echo "test" > 1/test
cat 1/test
```

0 comments on commit 8a7531f

Please sign in to comment.