Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(core): fix seg fault, use debian for base docker image #150

Merged
merged 6 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ runs:
context: .
build-args: |
"GIT_REV=${{ env.GIT_REV }}"
file: scripts/release/Dockerfile
file: scripts/release/Dockerfile.debian
platforms: ${{ inputs.platforms }}
load: ${{ inputs.load }}
push: ${{ inputs.push }}
Expand Down
22 changes: 2 additions & 20 deletions core/src/filesystem/media/rar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tracing::{debug, error, trace, warn};
use unrar::Archive;

use crate::{
config::{self, stump_in_docker},
config,
filesystem::{
archive::create_zip_archive,
content_type::ContentType,
Expand All @@ -23,8 +23,6 @@ use crate::{

use super::{FileProcessor, FileProcessorOptions, ProcessedFile};

const RAR_UNSUPPORTED_MSG: &str = "Stump cannot currently support RAR files in Docker.";

pub struct RarProcessor;

impl FileProcessor for RarProcessor {
Expand Down Expand Up @@ -69,11 +67,7 @@ impl FileProcessor for RarProcessor {
path: &str,
options: FileProcessorOptions,
) -> Result<ProcessedFile, FileError> {
if stump_in_docker() {
return Err(FileError::UnsupportedFileType(
RAR_UNSUPPORTED_MSG.to_string(),
));
} else if options.convert_rar_to_zip {
if options.convert_rar_to_zip {
let zip_path_buf =
RarProcessor::convert_to_zip(path, options.delete_conversion_source)?;
let zip_path = zip_path_buf.to_str().ok_or_else(|| {
Expand Down Expand Up @@ -122,12 +116,6 @@ impl FileProcessor for RarProcessor {
}

fn get_page(file: &str, page: i32) -> Result<(ContentType, Vec<u8>), FileError> {
if stump_in_docker() {
return Err(FileError::UnsupportedFileType(
RAR_UNSUPPORTED_MSG.to_string(),
));
}

let archive = Archive::new(file).open_for_listing()?;

let mut valid_entries = archive
Expand Down Expand Up @@ -175,12 +163,6 @@ impl FileProcessor for RarProcessor {
path: &str,
pages: Vec<i32>,
) -> Result<HashMap<i32, ContentType>, FileError> {
if stump_in_docker() {
return Err(FileError::UnsupportedFileType(
RAR_UNSUPPORTED_MSG.to_string(),
));
}

let archive = Archive::new(path).open_for_listing()?;

let entries = archive
Expand Down
78 changes: 78 additions & 0 deletions scripts/release/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ------------------------------------------------------------------------------
# Frontend Build Stage
# ------------------------------------------------------------------------------

FROM node:16-alpine3.14 as frontend
ARG TARGETARCH

WORKDIR /app

# Note: I don't like copying ~everything~ but since I now use types exported from
# the core, and use pnpm specific means of accessing it via the workspace, I kind
# of need to maintain the structure of the workspace and use pnpm
COPY . .

RUN npm install -g pnpm

RUN pnpm i
RUN pnpm web build

RUN mv ./apps/web/dist build

# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------

FROM rust:1.68.0-slim-buster AS builder

ARG GIT_REV
ENV GIT_REV=${GIT_REV}

WORKDIR /app

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
libssl-dev \
pkg-config \
libsqlite3-dev;


COPY . .
RUN ./scripts/release/build-utils.sh -w;

RUN set -ex; \
./scripts/release/build-utils.sh -p; \
cargo build --package stump_server --bin stump_server --release; \
cp ./target/release/stump_server ./stump_server

# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------

FROM debian:buster-slim

WORKDIR /

RUN mkdir -p config && mkdir -p data && mkdir -p app

COPY --from=builder /app/stump_server /app/stump
COPY --from=frontend /app/build /app/client

COPY scripts/release/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Default Stump environment variables
ENV STUMP_CONFIG_DIR=/config
ENV STUMP_CLIENT_DIR=/app/client
ENV STUMP_PROFILE=release
ENV STUMP_PORT=10801
ENV STUMP_IN_DOCKER=true


ENV API_VERSION=v1

WORKDIR /app

ENTRYPOINT ["/entrypoint.sh"]
3 changes: 2 additions & 1 deletion scripts/release/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ PLATFORMS=${2:-linux/amd64}
TAG=${3:-nightly}
GIT_REV=$(git rev-parse --short HEAD)

docker buildx build -f ./scripts/release/Dockerfile --load --progress=$FORMAT --platform=$PLATFORMS -t aaronleopold/stump:$TAG --build-arg GIT_REV=$GIT_REV .
# docker buildx build -f ./scripts/release/Dockerfile --load --progress=$FORMAT --platform=$PLATFORMS -t aaronleopold/stump:$TAG --build-arg GIT_REV=$GIT_REV .
docker buildx build -f ./scripts/release/Dockerfile.debian --progress=$FORMAT --platform=$PLATFORMS -t aaronleopold/stump-debian:$TAG --build-arg GIT_REV=$GIT_REV .
2 changes: 1 addition & 1 deletion scripts/release/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Depending on the values passed for PUID/PGID via environment variables,
# either starts the stump server daemon as root or as a regular user
Expand Down