Coder Social home page Coder Social logo

easy-add's Introduction

GitHub release (latest SemVer) test

A utility for easily adding a file from a downloaded archive during Docker builds

Usage

Running the binary with --help can be used to obtain usage at any time.

  -file path
    	The path to executable to extract within archive
  -from URL
    	URL of a tar.gz archive to download. May contain Go template references to 'var' entries.
  -mkdirs
    	Attempt to create the directory path specified by to
  -to path
    	The path where executable will be placed (default "/usr/local/bin")
  -var name=value
    	Sets variables that can be referenced in 'from'. Format is name=value (default os=linux,arch=amd64)
  -version
    	Show version and exit

Template variables in from

The from argument is process as a Go template with var as the context. For example, repetition in the URL can be simplified such as:

--var version=1.2.0 \
--from https://github.com/itzg/restify/releases/download/{{.version}}/restify_{{.version}}_{{.os}}_{{.arch}}.tar.gz

Example usage within Dockerfile

FROM ubuntu

ARG EASY_ADD_VER=0.5.3
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${EASY_ADD_VER}_linux_amd64 /usr/bin/easy-add
RUN chmod +x /usr/bin/easy-add

RUN easy-add --var version=1.2.0 --var app=restify --file restify --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_amd64.tar.gz

Dockerfile usage with BuildKit and multi-arch builds

# hook into docker BuildKit --platform support
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETVARIANT=""

ARG EASY_ADD_VER=0.5.3
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
RUN chmod +x /usr/bin/easy-add

Alternative when adding only a single archived-binary

easy-add is somewhat overkill adding only a single archived-binary to a Docker image. The following is an alternative solution that doesn't require curl to be installed in the image:

ADD https://github.com/itzg/rcon-cli/releases/download/1.4.7/rcon-cli_1.4.7_linux_amd64.tar.gz /tmp/rcon-cli.tgz
RUN tar -xf /tmp/rcon-cli.tgz -C /usr/local/bin rcon-cli && rm /tmp/rcon-cli.tgz

easy-add's People

Contributors

dependabot[bot] avatar goliathlabs avatar itzg avatar strausmann avatar timomeijer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

easy-add's Issues

/usr/bin/easy-add: 7: /usr/bin/easy-add: Syntax error: newline unexpected

Hello ! I'm new to Dockefiles and I'm trying to use the command you created easy-add in my Dockerfile for a project but I'm getting this error permanently and I'm pretty sure it doesn't come from my code as the error is focusing on the "line 7".
In fact I think that it comes from one of your files.

FROM ubuntu:latest

ARG DEBIAN_FRONTEND=noninteractive

# Applications that will be installed in the docker
RUN apt-get update && \
	apt-get install -y --no-install-recommends \
	vsftpd \
	db-util \
    openssl \
    imagemagick \
    lsof \
    fakeroot build-essential devscripts \
#    shadow \
    bash \
    curl iputils-arping wget \
    git \
    jq \
    mysql-client \
    tzdata \
    apt-transport-https \
    rsync \
    nano && \
    apt-get clean

HEALTHCHECK --start-period=1m CMD mc-monitor status --host localhost --port $SERVER_PORT

RUN groupadd -g 1000 minecraft \
	&& mkdir -m 777 /home/minecraft \
	&& useradd minecraft -s /bin/false -u 1000 -g minecraft -d /home/minecraft \
	&& mkdir -m 777 /data \
	&& chown minecraft:minecraft /data /home/minecraft

EXPOSE 25565 25575

# hook into docker BuildKit --platform support
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETVARIANT=""

ARG EASY_ADD_VER=0.7.1
ADD https://github.com/itzg/easy-add/releases/tag/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
RUN chmod +x /usr/bin/easy-add

RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
	--var version=1.2.0 --var app=restify --file {{.app}} \
	--from https://github.com/itzg/{{.app}}/releases/tag/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz

RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
	--var version=1.4.7 --var app=rcon-cli --file {{.app}} \
	--from https://github.com/itzg/{{.app}}/releases/tag/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz

RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
	--var version=0.1.7 --var app=mc-monitor --file {{.app}} \
	--from https://github.com/itzg/{{.app}}/releases/tag/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz

RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
	--var version=1.4.2 --var app=mc-server-runner --file {{.app}} \
	--from https://github.com/itzg/{{.app}}/releases/tag/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz

RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
	--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
	--from https://github.com/itzg/{{.app}}/releases/tag/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz

COPY mcstatus /usr/local/bin

VOLUME ["/data"]
COPY server.properties /tmp/server.properties
COPY log4j2.xml /tmp/log4j2.xml
WORKDIR /data

ENTRYPOINT [ "/start" ]

ENV UID=1000 GID=1000 \
  MEMORY="1G" \
  TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
  PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
  LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
  REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_"

COPY start* /
RUN dos2unix /start* && chmod +x /start*

ENV FTP_USER admin
ENV FTP_PASS admin
ENV PASV_ADDRESS REQUIRED

COPY vsftpd.conf /etc/vsftpd/
COPY vsftpd_virtual /etc/pam.d/
COPY run-vsftpd.sh /usr/sbin/

RUN chmod +x /usr/sbin/run-vsftpd.sh && \
        mkdir -p /var/run/vsftpd/empty

VOLUME /home/vsftpd
VOLUME /var/log/vsftpd

EXPOSE 20 21

CMD ["/usr/sbin/run-vsftpd.sh"]

image

I would be very glad if could help me with my issue @itzg

aarch64 release

Hi itzg,

could you please release easy-add for aarch64?
Im trying to start your minecraft container image on pi4-64 for fun.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.