Skip to content

Commit 4db3f30

Browse files
committed
.github/Dockerfile with pkgx support
1 parent ec8dd7e commit 4db3f30

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**
2+
!.pkgx.yaml
3+
!lib/**/*
4+
!mix.exs

.github/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM pkgxdev/pkgx as base
2+
# Set locale to utf8, without this Elixir warns:
3+
# > the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8.
4+
# > Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
5+
# > or set the ELIXIR_ERL_OPTIONS="+fnu" environment variable
6+
RUN apt-get -y install locales
7+
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
8+
ENV LANG en_US.UTF-8
9+
ENV LANGUAGE en_US:en
10+
ENV LC_ALL en_US.UTF-8
11+
12+
FROM base as build
13+
WORKDIR /action/workspace
14+
15+
# System dependencies
16+
COPY ../.pkgx.yaml .
17+
RUN eval "$(pkgx --internal.activate $PWD)"
18+
19+
# Mix dependencies
20+
COPY ../mix.exs .
21+
RUN eval "$(pkgx --internal.activate $PWD)" && mix deps.get
22+
23+
# Compile
24+
COPY ../lib lib
25+
RUN eval "$(pkgx --internal.activate $PWD)" && mix deps.compile
26+
RUN eval "$(pkgx --internal.activate $PWD)" && mix escript.build
27+
28+
FROM base as release
29+
COPY --from=build /root/.pkgx /root/.pkgx
30+
COPY --from=build /action/workspace/.pkgx.yaml /usr/local/bin
31+
COPY --from=build /action/workspace/elixir_script /usr/local/bin
32+
RUN echo '#!/bin/sh\n\
33+
eval "$(pkgx --internal.activate /usr/local/bin)"\n\
34+
exec /usr/local/bin/elixir_script "$@"' > /usr/local/bin/elixir_script_wrapper && \
35+
chmod +x /usr/local/bin/elixir_script_wrapper
36+
37+
ENTRYPOINT ["elixir_script_wrapper"]

Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)