83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
FROM elixir:1.11 AS build
 | 
						|
 | 
						|
# install build dependencies
 | 
						|
RUN set -eux \
 | 
						|
    &&  apt-get update \
 | 
						|
    &&  apt-get install -y --no-install-recommends \
 | 
						|
    apt-transport-https \
 | 
						|
    ca-certificates \
 | 
						|
    curl \
 | 
						|
    &&  curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor > /etc/apt/trusted.gpg.d/nodesource.gpg \
 | 
						|
    &&  echo "deb https://deb.nodesource.com/node_14.x stretch main" > /etc/apt/sources.list.d/nodesource.list \
 | 
						|
    &&  apt-get update \
 | 
						|
    &&  apt-get install -y --no-install-recommends \
 | 
						|
    nodejs \
 | 
						|
    &&  apt-get clean \
 | 
						|
    &&  rm -rf /var/lib/apt/lists/*
 | 
						|
 | 
						|
# prepare build dir
 | 
						|
WORKDIR /opt/confient
 | 
						|
 | 
						|
# install hex + rebar
 | 
						|
RUN mix local.hex --force && \
 | 
						|
    mix local.rebar --force
 | 
						|
 | 
						|
# set build ENV
 | 
						|
ENV MIX_ENV=prod
 | 
						|
 | 
						|
# install mix dependencies
 | 
						|
COPY mix.exs mix.lock ./
 | 
						|
COPY config config
 | 
						|
RUN mix do deps.get, deps.compile
 | 
						|
 | 
						|
# build assets
 | 
						|
COPY assets/package.json assets/package-lock.json ./assets/
 | 
						|
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
 | 
						|
 | 
						|
COPY priv priv
 | 
						|
COPY assets assets
 | 
						|
RUN npm run --prefix ./assets deploy
 | 
						|
RUN mix phx.digest
 | 
						|
 | 
						|
# compile and build release
 | 
						|
COPY lib lib
 | 
						|
# uncomment COPY if rel/ exists
 | 
						|
# COPY rel rel
 | 
						|
RUN mix do compile, release
 | 
						|
 | 
						|
# prepare release image
 | 
						|
FROM elixir:1.11 AS app
 | 
						|
 | 
						|
RUN set -eux \
 | 
						|
    &&  apt-get update \
 | 
						|
    &&  apt-get install -y --no-install-recommends \
 | 
						|
    postgresql-client \
 | 
						|
    &&  apt-get clean \
 | 
						|
    &&  rm -rf /var/lib/apt/lists/*
 | 
						|
 | 
						|
RUN useradd -ms /bin/bash confient
 | 
						|
 | 
						|
RUN mkdir -p /opt/confient /srv/confient/uploads
 | 
						|
 | 
						|
WORKDIR /opt/confient
 | 
						|
 | 
						|
RUN chown confient:confient /opt/confient /srv/confient/uploads
 | 
						|
 | 
						|
USER confient
 | 
						|
 | 
						|
COPY --from=build --chown=confient:confient /opt/confient/_build/prod/rel/confient ./
 | 
						|
 | 
						|
COPY entrypoint.sh /opt/confient/entrypoint.sh
 | 
						|
 | 
						|
ENV HOME=/opt/confient
 | 
						|
 | 
						|
# image-spec annotations using labels
 | 
						|
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
 | 
						|
LABEL org.opencontainers.image.source="https://git.athelas-conseils.fr/papey/confient"
 | 
						|
LABEL org.opencontainers.image.authors="Wilfried OLLIVIER"
 | 
						|
LABEL org.opencontainers.image.title="Confient"
 | 
						|
LABEL org.opencontainers.image.description="Confient runtime"
 | 
						|
LABEL org.opencontainers.image.licences="Unlicense"
 | 
						|
 | 
						|
CMD ["./entrypoint.sh"]
 |