Skip to content
Snippets Groups Projects
Dockerfile 1.94 KiB
ARG IMAGE_SERVER="registry.420joos.dev"
ARG FLUTTER_VERSION="3.24.5"
ARG DEPENDENCY_DIR="/tmp/dependencies"
ARG FLUTTER_DIR="opt/flutter"

FROM ubuntu:24.04 AS download

ARG FLUTTER_URL
ARG FLUTTER_VERSION
ARG DEPENDENCY_DIR
ARG FLUTTER_DIR
ARG FLUTTER_DIR="$DEPENDENCY_DIR/${FLUTTER_DIR}"
ARG FLUTTER_DOWNLOAD_FILE="flutter.tar.xz"

RUN apt update \
    && apt install -y wget xz-utils git curl unzip

RUN mkdir -p ${FLUTTER_DIR}

RUN if [ "$(uname -m)" = "x86_64" ]; then \
    wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz -O ${FLUTTER_DOWNLOAD_FILE} \
    && tar -xf ${FLUTTER_DOWNLOAD_FILE} --strip-components=1 --directory $FLUTTER_DIR; \
    fi

# Flutter on arch currently has warnings because channel and repository source are not set
RUN if [ "$(uname -m)" = "aarch64" ]; then \
    git clone https://github.com/flutter/flutter.git ${FLUTTER_DIR} \
    && cd ${FLUTTER_DIR} \
    && git fetch origin tag ${FLUTTER_VERSION} \
    && git checkout tags/${FLUTTER_VERSION} \
    && ${FLUTTER_DIR}/bin/flutter doctor; \
    fi


FROM alpine:3.20.3

ARG DEPENDENCY_DIR
ARG FLUTTER_DIR

ARG USER_UID="1000"
ARG USER_GID=${USER_UID}
ARG USERNAME="flutter"

ENV FLUTTER_DIR="/${FLUTTER_DIR}"
ENV PATH=${PATH}:${FLUTTER_DIR}/bin

COPY --from=download $DEPENDENCY_DIR /

RUN apk add --no-cache bash git gcompat \
    && addgroup ${USERNAME} -g ${USER_GID} \
    && adduser ${USERNAME} --uid ${USER_UID} --ingroup ${USERNAME} --disabled-password \
    && chown -R ${USERNAME}:${USERNAME} ${FLUTTER_DIR}

USER ${USERNAME}
WORKDIR /home/${USERNAME}

RUN dart --disable-analytics \
    && flutter config \
    --no-analytics \
    --no-enable-web \
    --no-enable-linux-desktop \
    --no-enable-macos-desktop \
    --no-enable-windows-desktop \
    --no-enable-android \
    --no-enable-ios \
    --no-enable-fuchsia \
    && flutter precache --universal

# Test flutter
# RUN flutter doctor --verbose && exit 1