diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c46617a..55c6591 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,5 +39,5 @@ jobs: --platform linux/arm64,linux/amd64,linux/arm/v7 \ --cache-from octoprint/octoprint:cache \ --cache-to octoprint/octoprint:cache \ - --build-arg OCTOPRINT_BASE_IMAGE=${{ steps.get-octoprint-release.outputs.release }} \ + --build-arg tag=${{ steps.get-octoprint-release.outputs.release }} \ --progress plain -t octoprint/octoprint:ci -f Dockerfile . diff --git a/.github/workflows/octoprint-release.yml b/.github/workflows/octoprint-release.yml index d754b43..3009d04 100644 --- a/.github/workflows/octoprint-release.yml +++ b/.github/workflows/octoprint-release.yml @@ -74,6 +74,6 @@ jobs: --platform linux/arm64,linux/amd64,linux/arm/v7 \ --cache-from octoprint/octoprint:cache \ --cache-to octoprint/octoprint:cache \ - --build-arg OCTOPRINT_BASE_IMAGE=${{ steps.get-octoprint-release.outputs.release }} \ + --build-arg tag=${{ env.tag_name }} \ --progress plain -t octoprint/octoprint:${{ steps.tagging.outputs.tag }} -f Dockerfile . diff --git a/Dockerfile b/Dockerfile index 8817545..765d1c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG OCTOPRINT_BASE_IMAGE +ARG PYTHON_BASE_IMAGE=3.8-slim-buster FROM ubuntu AS s6build ARG S6_RELEASE @@ -18,9 +18,10 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && curl -fsSLO "https://github.com/just-containers/s6-overlay/releases/download/$S6_VERSION/s6-overlay-$ARCH.tar.gz" -FROM octoprint/octoprint:${OCTOPRINT_BASE_IMAGE} AS build +FROM python:${PYTHON_BASE_IMAGE} AS build -USER root +ARG tag +ENV tag ${tag:-master} RUN apt-get update && apt-get install -y \ avrdude \ @@ -28,6 +29,7 @@ RUN apt-get update && apt-get install -y \ cmake \ curl \ imagemagick \ + ffmpeg \ fontconfig \ g++ \ git \ @@ -46,6 +48,17 @@ COPY --from=s6build /tmp /tmp RUN s6tar=$(find /tmp -name "s6-overlay-*.tar.gz") \ && tar xzf $s6tar -C / +# Install octoprint +RUN curl -fsSLO --compressed --retry 3 --retry-delay 10 \ + https://github.com/OctoPrint/OctoPrint/archive/${tag}.tar.gz \ + && mkdir -p /opt/octoprint \ + && tar xzf ${tag}.tar.gz --strip-components 1 -C /opt/octoprint --no-same-owner + +WORKDIR /opt/octoprint +RUN pip install -r requirements.txt +RUN python setup.py install +RUN ln -s ~/.octoprint /octoprint + # Install mjpg-streamer RUN curl -fsSLO --compressed --retry 3 --retry-delay 10 \ https://github.com/jacksonliam/mjpg-streamer/archive/master.tar.gz \ @@ -60,9 +73,13 @@ RUN make install COPY root / ENV CAMERA_DEV /dev/video0 ENV MJPEG_STREAMER_INPUT -y -n -r 640x480 +ENV PIP_USER true +ENV PYTHONUSERBASE /octoprint/plugins # port to access haproxy frontend EXPOSE 80 +VOLUME /octoprint + ENTRYPOINT ["/init"] CMD ["octoprint", "serve", "--iknowwhatimdoing", "--host", "0.0.0.0"] diff --git a/Makefile b/Makefile index 4c43e15..4362e32 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ buildx-test: --cache-to ${CACHE} \ --build-arg PYTHON_BASE_IMAGE=$(PYTHON_BASE_IMAGE) \ --build-arg tag=${OCTOPRINT_VERSION} \ - --progress plain -t ${IMG}:ci . + --progress tty -t ${IMG}:ci . buildx-push: @echo '[buildx]: building and pushing images: ${IMG}:${IMG_TAG} for all supported architectures' diff --git a/README.md b/README.md index f79fee6..539db4a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ launch of OctoPrint using docker. Use the following values in the webcam & timelapse settings screen of the initial setup: | Setting | Value | -|=========|=======| +| ------- | ----- | | Stream URL | `/webcam/?action=stream` | | Snapshot URL | `http://localhost:8080/?action=snapshot` | | Path to FFMPEG | `/usr/bin/ffmpeg` | @@ -39,7 +39,7 @@ Listed below are the options and their defaults. These are implicit in example [ and if you wish to change them, refer to the docker-compose docs on setting environment variables. | variable | default | -|==========|=========| +| -------- | ------- | | `CAMERA_DEV` | `/dev/video0` (see [note](#devices_note)) | | `CAMERA_DEV` | `MJPEG_STREAMER_INPUT -y -n -r 640x48` | @@ -52,27 +52,30 @@ in your container. #### Editing Config files manually -This docker-compose file also contains a container based instance of vscode, accessible +This docker-compose file also contains a container based instance of [vscode][], accessible via your browser at the same url as your octoprint instance, allowing you to edit configuration files without needing to login to your octoprint host. -To make use of this editor, just uncomment the indicated lines in your [docker-compose.yml](docker-compose.yml#20-32) +To make use of this editor, just uncomment the indicated lines in your [docker-compose.yml](docker-compose.yml#L20-L32) then run the following commands: ``` docker-compose up -d config-editor ``` -Now go to `http://:8443` in your browser to edit your octoprint files! +Now go to `http://:8443/?folder=/config` in your browser to edit your octoprint files! Use the 'explorer' (accessible by clicking the hamburger menu icon) to explore folder and files to load into the editor workspace. +The active configuration will be accessible at `/config/config.yaml` + When you're done, we recommend you stop and rm this service/container: ``` docker-compose stop config-editor && docker-compose rm config-editor ``` +For full documenation about the config editor, see the docs for the product at [github.com/cdr/code-server][code-server]. ## Without docker-compose @@ -84,3 +87,6 @@ docker volume create octoprint docker run -d -v octoprint:/octoprint --device /dev/ttyACM0:/dev/ttyACM0 --device /dev/video0:/dev/video0 -p 80:80 --name octoprint octoprint/octoprint ``` + +[code-server]: https://github.com/cdr/code-server +[vscode]: https://code.visualstudio.com diff --git a/docker-compose.yml b/docker-compose.yml index 4183506..5ac2920 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: # - GUID=0 # - TZ=America/Chicago # volumes: - # - octoprint:/octoprint + # - octoprint:/config volumes: octoprint: