Skip to content

Commit

Permalink
fix: docker works-ish
Browse files Browse the repository at this point in the history
  • Loading branch information
cs50victor committed Feb 15, 2024
1 parent 1c3ab78 commit 64e5ddd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 101 deletions.
138 changes: 38 additions & 100 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,106 +1,44 @@
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as builder

WORKDIR /usr/src/app

FROM rust as planner
WORKDIR /app
RUN cargo install cargo-chef
COPY . .

# Build the application
RUN cargo chef prepare --recipe-path recipe.json

FROM rust as cacher
WORKDIR /app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json
# Build tools
RUN apt-get update
RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth
RUN cargo chef cook --release --features docker --recipe-path=recipe.json

FROM rust as builder
COPY . /app
WORKDIR /app
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
# Build tools
RUN apt-get update
RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth
RUN cargo build --release --features docker

# --------------------------------------------------
# FROM fedora:latest

# WORKDIR /usr/src/app

# USER root

# ENV DEBIAN_FRONTEND=noninteractive

# # # Install necessary build dependencies
# RUN dnf update -y && dnf install -y gcc-c++ libX11-devel alsa-lib-devel systemd-devel wayland-devel libxkbcommon-devel weston libXcursor libXrandr
# # RUN dnf update -y && dnf install -y \
# # pkg-config \
# # weston \
# # xwayland \
# # kbd \
# # dos2unix \
# # libasound2-dev \
# # libudev-dev \
# # mesa-utils \
# # vulkan-tools \
# # libwayland-dev \
# # libxkbcommon-dev \
# # libvulkan1 \
# # libvulkan-dev \
# # libegl1-mesa-dev \
# # libgles2-mesa-dev \
# # libx11-dev \
# # libxcursor-dev \
# # libxrandr-dev \
# # libxi-dev \
# # libxrandr-dev \
# # libxcb1-dev \
# # libxcb-icccm4-dev \
# # libxcb-image0-dev \
# # libxcb-keysyms1-dev \
# # libxcb-randr0-dev \
# # libxcb-shape0-dev \
# # libxcb-xfixes0-dev \
# # libxcb-xkb-dev \
# # libegl1-mesa \
# # libgl1-mesa-glx \
# # libgl1-mesa-dri \
# # libglu1-mesa-dev \
# # libglu1-mesa \
# # libgles2-mesa \
# # && apt-get clean \
# # && rm -rf /var/lib/apt/lists/*

# RUN mkdir tmp/

# ENV XDG_RUNTIME_DIR=tmp
# ENV WLR_BACKENDS=headless
# ENV WLR_LIBINPUT_NO_DEVICES=1
# ENV WAYLAND_DISPLAY=wayland-0
# ENV DISPLAY=:1

# COPY --from=builder /usr/src/app/target/release/new_media .
# ENV RUST_BACKTRACE=1

# EXPOSE 8080
FROM ubuntu:22.04
COPY --from=builder /app/target/release/new_media /app/new_media
WORKDIR /app

# Build tools
RUN apt-get update
RUN apt-get install -y -qq build-essential software-properties-common pkg-config xorg openbox xauth
# Bevy dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -yq libasound2-dev libudev-dev libxkbcommon-x11-0
RUN apt-get update -y -qq
RUN add-apt-repository ppa:kisak/turtle -y
RUN apt-get update
RUN apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
ENV CARGO_TARGET_DIR="../rust-target"
ENV PATH="/root/.cargo/bin:${PATH}"

# CMD ["./new_media"]


# ----------------- TESTING

FROM registry.fedoraproject.org/fedora-minimal:37
RUN microdnf install -y --setopt install_weak_deps=0 busybox spice-html5 python3-websockify novnc weston labwc sway wayvnc dbus-daemon procps-ng foot wofi bemenu google-noto-naskh-arabic-fonts dejavu-fonts-all ; microdnf clean all

RUN mkdir /opt/busybox; \
/sbin/busybox --install -s /opt/busybox
ENV PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/busybox
RUN cp /usr/share/weston/background.png /usr/share/backgrounds/default.png ; \
busybox adduser -D app ; \
busybox passwd -l app ; \
mkdir -p /home/app/tmp ; busybox chown app:app /home/app/tmp
ADD sway /etc/sway/config.d/sway
ADD labwc /etc/xdg/labwc

USER app
ENV SHELL=/bin/bash
ENV PATH=/home/app/.local/bin:/home/app/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/busybox
ENV XDG_RUNTIME_DIR=/home/app/tmp
ENV WLR_BACKENDS=headless
ENV WLR_LIBINPUT_NO_DEVICES=1
ENV WAYLAND_DISPLAY=wayland-1

ADD start.sh /start.sh

EXPOSE 5900
EXPOSE 8080


ENTRYPOINT ["/start.sh"]


CMD xvfb-run -s "-screen 0 1280x1024x24" "./new_media"
2 changes: 1 addition & 1 deletion new_media/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ tungstenite = { workspace = true }
openssl = { version = "0.10.63", features = ["vendored"], optional = true}

[features]
docker = ["dep:openssl","bevy/wayland", "bevy/x11"]
docker = ["dep:openssl","bevy/x11"]

0 comments on commit 64e5ddd

Please sign in to comment.