Reputation: 771
My Dockerfile
FROM ubuntu:18.04
# Project files
ARG PROJECT_DIR=/srv/api
RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
# Update
RUN apt-get -y upgrade
RUN apt-get update
RUN apt-get install -y xz-utils
RUN apt-get install -y curl
RUN curl https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.7.8+hotfix.4-stable.tar.xz -o /flutter.tar.xz
RUN tar xf /flutter.tar.xz
#RUN mv flutter /srv/api/flutter
RUN ls /srv/api/flutter
RUN chmod a+x /srv/api/flutter
RUN flutter doctor
# Install Flutter dependencies
RUN flutter upgrade
RUN flutter packages pub global activate webdev
RUN flutter packages upgrade
# Copy everything to Docker
COPY ./ ./
Fails at RUN flutter doctor
If I put in path /srv/api/flutter
I receive error flutter: not found
.
If I put in path /usr/local/bin/flutter
I receive error flutter: Permission Denied
.
I tried putting it in regular directory and in /usr directory. Both ways have failed. I tried searching about it but nothing seems to be working.
How can I fix it?
Upvotes: 1
Views: 2283
Reputation: 4150
flutter
is available in the ./bin/
directory of the flutter
package. Slightly modified Dockerfile
:
FROM ubuntu:18.04
ARG PROJECT_DIR=/srv/api
ENV PATH=/opt/flutter/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN apt-get update && \
apt-get install -y \
xz-utils \
git \
openssh-client \
curl && \
rm -rf /var/cache/apt
RUN curl -L https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.7.8+hotfix.4-stable.tar.xz | tar -C /opt -xJ
WORKDIR ${PROJECT_DIR}
COPY ./ ./
RUN flutter doctor
RUN flutter upgrade
RUN flutter packages pub global activate webdev
RUN flutter packages upgrade
This example extracts the flutter
package to /opt
and sets /opt/flutter/bin
in the $PATH
- the flutter
executable is at /opt/flutter/bin/flutter
.
Note:
WORKDIR
creates the directory if it doesn't already exist -
removing the RUN mkdir -p $PROJECT_DIR
removes a layer from the
final image (RUN
, COPY
and ADD
create layers).apt-get update && apt-get install -y ...
and removed the apt-get upgrade
for reasons stated in
the
documentation.diff
imo.curl | tar
.ls /srv/api/flutter
and chmod a+x /srv/api/flutter
RUN
's.Upvotes: 2