fix: docker support improvements
- Build the binary with Mage. - Set the ENTRYPOINT to "spruce". - Add instructions on building and using the docker image.
This commit is contained in:
parent
c53978cd91
commit
93da4f6648
|
@ -1,5 +0,0 @@
|
|||
*
|
||||
!*.go
|
||||
!templates/*
|
||||
!go.mod
|
||||
!go.sum
|
|
@ -1,23 +1,32 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM golang:1.21-buster AS spruce-builder
|
||||
FROM golang:1.21-alpine AS builder
|
||||
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOOS=linux
|
||||
ENV GOARCH=amd64
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
RUN apk add --no-cache git \
|
||||
&& git clone https://github.com/magefile/mage
|
||||
|
||||
WORKDIR /tmp/mage
|
||||
|
||||
RUN go run bootstrap.go
|
||||
|
||||
COPY . /workspace
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN go build -a -v -o /workspace/spruce
|
||||
RUN mage build
|
||||
|
||||
FROM alpine:3.18
|
||||
|
||||
COPY --from=spruce-builder /workspace/spruce /usr/local/bin
|
||||
COPY --from=builder /workspace/spruce /usr/local/bin
|
||||
|
||||
# Install dependencies
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add \
|
||||
&& apk add --no-cache \
|
||||
font-carlito \
|
||||
aspell \
|
||||
curl \
|
||||
|
@ -34,3 +43,5 @@ RUN curl -LO http://lmtx.pragma-ade.com/install-lmtx/context-linuxmusl.zip \
|
|||
ENV PATH=${PATH}:/opt/context/tex/texmf-linuxmusl/bin
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
ENTRYPOINT ["spruce"]
|
|
@ -57,6 +57,12 @@ The project includes a https://codeflow.dananglin.me.uk/apollo/spruce/src/branch
|
|||
With Mage the build information is built into the binary when it is compiled.
|
||||
You can visit the https://magefile.org[website] for instructions on how to install Mage.
|
||||
|
||||
=== Docker (Optional)
|
||||
|
||||
You can use Docker to build and use a docker image built with spruce and ConText installed.
|
||||
This could be useful for those who are comfortable using Docker and don't want to install the above dependencies
|
||||
directly onto their machines.
|
||||
|
||||
== Installation
|
||||
|
||||
=== With Mage
|
||||
|
@ -87,6 +93,16 @@ cd spruce
|
|||
go install .
|
||||
----
|
||||
|
||||
=== Building the Docker image
|
||||
|
||||
You can build a docker image using the Dockerfile included in this project.
|
||||
The build will build and install the spruce binary as well as install all the required dependencies in the final image.
|
||||
You can build the docker image with the following command:
|
||||
[source,console]
|
||||
----
|
||||
docker build -t spruce .
|
||||
----
|
||||
|
||||
=== Verifying the installation
|
||||
|
||||
Run `spruce` to verify your installation. You should see the usage printed onto your screen.
|
||||
|
@ -112,6 +128,13 @@ Flags:
|
|||
Use "spruce [command] --help" for more information about a command.
|
||||
----
|
||||
|
||||
If you've build the docker image you can get the same help message with the following command:
|
||||
|
||||
[source,console]
|
||||
----
|
||||
docker run --rm -it spruce
|
||||
----
|
||||
|
||||
If you have installed spruce with Mage, you can get the build information to confirm that you have installed the correct version.
|
||||
[source,console]
|
||||
----
|
||||
|
@ -123,16 +146,30 @@ Spruce
|
|||
Build date: 2023-08-12T13:00:51Z
|
||||
----
|
||||
|
||||
If you've built the docker image you can verify it with the following command:
|
||||
[source,console]
|
||||
----
|
||||
docker run --rm spruce version --full
|
||||
----
|
||||
|
||||
== Generating the example PDF Document
|
||||
|
||||
Once you've installed spruce you can generate a PDF from the example CV by running the following command:
|
||||
Once you've installed spruce you can generate a PDF file from the example CV by running the following command:
|
||||
|
||||
[source,console]
|
||||
----
|
||||
spruce generate --input example/cv.json
|
||||
----
|
||||
|
||||
This will create a file called `cv.pdf` which you can view in your favourite PDF viewer.
|
||||
This will create a file called `cv.pdf` which you can view with your favourite PDF viewer.
|
||||
|
||||
If you're using the docker image you can generate the PDF file using the following command:
|
||||
[source,console]
|
||||
----
|
||||
docker run --rm -v ./example:/workspace spruce generate --input cv.json --output cv.pdf
|
||||
----
|
||||
|
||||
The PDF file will be created in the `example` folder.
|
||||
|
||||
== Inspirations
|
||||
|
||||
|
|
Loading…
Reference in a new issue