Skip to content

Commit

Permalink
add some examples
Browse files Browse the repository at this point in the history
remove openssh deps
move devcontainer stuff to dedicated folder
  • Loading branch information
radumarias committed May 9, 2024
1 parent 69e1e3a commit 94e371e
Show file tree
Hide file tree
Showing 15 changed files with 1,978 additions and 225 deletions.
43 changes: 43 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use an argument to specify the Ubuntu version, with a default
ARG UBUNTU_VERSION=20.04

# Use the specified Ubuntu version from the .env file
FROM ubuntu:${UBUNTU_VERSION}

ARG USER_NAME=developer
ARG USER_HOME=/home/developer
ARG PROJECT_NAME=rencfs

ENV USER_NAME=${USER_NAME}
ENV USER_HOME=${USER_HOME}
ENV PROJECT_NAME=${PROJECT_NAME}

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
sudo \
git \
curl \
gcc \
pkg-config \
build-essential \
libssl-dev \
fuse3

RUN useradd -m -s /bin/bash -d ${USER_HOME} ${USER_NAME} \
&& echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME} \
&& chmod 0440 /etc/sudoers.d/${USER_NAME}

# Switch to the new user
USER ${USER_NAME}
WORKDIR ${USER_HOME}

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

# Set the environment variables needed for Rust
ENV PATH="${USER_HOME}/.cargo/bin:${PATH}"

WORKDIR ${USER_HOME}/${PROJECT_NAME}

# Command to keep the container running
CMD ["sleep", "infinity"]
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml → .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
rencfs-development-environment:
build:
context: .
context: ..
dockerfile: Dockerfile
image: local-rencfs-developer
user: ${USER_NAME}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/target
.idea
61 changes: 27 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
# Use an argument to specify the Ubuntu version, with a default
ARG UBUNTU_VERSION=20.04
################
##### Builder
FROM alpine:3.16.0 as builder

# Use the specified Ubuntu version from the .env file
FROM ubuntu:${UBUNTU_VERSION}
RUN apk add binutils build-base ca-certificates curl file g++ gcc make patch rust

ARG USER_NAME=developer
ARG USER_HOME=/home/developer
ARG PROJECT_NAME=rencfs

ENV USER_NAME=${USER_NAME}
ENV USER_HOME=${USER_HOME}
ENV PROJECT_NAME=${PROJECT_NAME}

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

RUN apt-get update && apt-get install -y \
sudo \
git \
curl \
gcc \
pkg-config \
build-essential \
libssl-dev \
fuse3
RUN . ~/.cargo/env && rustup target add x86_64-unknown-linux-musl

RUN useradd -m -s /bin/bash -d ${USER_HOME} ${USER_NAME} \
&& echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME} \
&& chmod 0440 /etc/sudoers.d/${USER_NAME}
# Cache downloaded+built dependencies
#COPY Cargo.toml Cargo.lock /usr/src/rencfs/
#RUN mkdir /usr/src/rencfs/src && \
# echo 'fn main() {}' > /usr/src/rencfs/src/main.rs
#
#RUN . ~/.cargo/env && cd /usr/src/rencfs/ && cargo build --release && \
# rm -Rvf /usr/src/rencfs/src

# Switch to the new user
USER ${USER_NAME}
WORKDIR ${USER_HOME}
# Build our actual code
COPY Cargo.toml Cargo.lock /usr/src/rencfs/
COPY src /usr/src/rencfs/src
RUN . ~/.cargo/env && \
cd /usr/src/rencfs/ && \
cargo build --target x86_64-unknown-linux-musl --release

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
################
##### Runtime
FROM alpine:3.16.0 AS runtime

# Set the environment variables needed for Rust
ENV PATH="${USER_HOME}/.cargo/bin:${PATH}"
RUN apk add fuse3

WORKDIR ${USER_HOME}/${PROJECT_NAME}
# Copy application binary from builder image
COPY --from=builder /usr/src/rencfs/target/x86_64-unknown-linux-musl/release/rencfs /usr/local/bin

# Command to keep the container running
CMD ["sleep", "infinity"]
# Run the application
CMD ["rencfs", "--help"]
37 changes: 0 additions & 37 deletions Dockerfile.backup

This file was deleted.

Loading

0 comments on commit 94e371e

Please sign in to comment.