-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial dev container for building on macos with arm cpu
- Loading branch information
1 parent
c2cdc5e
commit e14b507
Showing
6 changed files
with
93 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
UBUNTU_VERSION=20.04 | ||
USER_NAME=developer | ||
USER_HOME=/home/developer | ||
PROJECT_NAME=rencfs | ||
|
||
PROJECT_HOME=${USER_HOME}/${PROJECT_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
################ | ||
##### Builder | ||
FROM alpine:3.16.0 as builder | ||
# Use an argument to specify the Ubuntu version, with a default | ||
ARG UBUNTU_VERSION=20.04 | ||
|
||
RUN apk add binutils build-base ca-certificates curl file g++ gcc libressl-dev make patch rust | ||
# Use the specified Ubuntu version from the .env file | ||
FROM ubuntu:${UBUNTU_VERSION} | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
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} | ||
|
||
RUN . ~/.cargo/env && rustup target add x86_64-unknown-linux-musl | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# 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 | ||
RUN apt-get update && apt-get install -y \ | ||
sudo \ | ||
git \ | ||
curl \ | ||
gcc \ | ||
pkg-config \ | ||
build-essential \ | ||
libssl-dev \ | ||
fuse3 | ||
|
||
# Build our actual code | ||
COPY Cargo.toml Cargo.lock /usr/src/rencfs/ | ||
COPY src /usr/src/rencfs/src | ||
RUN touch /usr/src/rencfs/src/main.rs | ||
RUN . ~/.cargo/env && \ | ||
cd /usr/src/rencfs/ && \ | ||
cargo build --target x86_64-unknown-linux-musl --release | ||
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} | ||
|
||
################ | ||
##### Runtime | ||
FROM alpine:3.16.0 AS runtime | ||
# 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 | ||
|
||
RUN apk add fuse3 | ||
# Set the environment variables needed for Rust | ||
ENV PATH="${USER_HOME}/.cargo/bin:${PATH}" | ||
|
||
# Copy application binary from builder image | ||
COPY --from=builder /usr/src/rencfs/target/x86_64-unknown-linux-musl/release/rencfs /usr/local/bin | ||
WORKDIR ${USER_HOME}/${PROJECT_NAME} | ||
|
||
# Run the application | ||
CMD ["rencfs", "--help"] | ||
# Command to keep the container running | ||
CMD ["sleep", "infinity"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
################ | ||
##### Builder | ||
FROM alpine:3.16.0 as builder | ||
|
||
RUN apk add binutils build-base ca-certificates curl file g++ gcc libressl-dev make patch 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/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 | ||
|
||
# Build our actual code | ||
COPY Cargo.toml Cargo.lock /usr/src/rencfs/ | ||
COPY src /usr/src/rencfs/src | ||
RUN touch /usr/src/rencfs/src/main.rs | ||
RUN . ~/.cargo/env && \ | ||
cd /usr/src/rencfs/ && \ | ||
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/rencfs/target/x86_64-unknown-linux-musl/release/rencfs /usr/local/bin | ||
|
||
# Run the application | ||
CMD ["rencfs", "--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "rencfs docker development environment", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "rencfs-development-environment", | ||
"shutdownAction": "stopCompose" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
rencfs-development-environment: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
image: local-rencfs-developer | ||
user: ${USER_NAME} | ||
volumes: | ||
- .:/home/developer/rencfs |