Skip to content

Commit a9e2574

Browse files
committed
feat(elxir:gsmlg): Add docker build.
1 parent 03b983b commit a9e2574

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

.github/workflows/elixir-gsmlg-build-and-release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,37 @@ jobs:
2222

2323
- name: 🚀 Release
2424
uses: gsmlg/semantic-release-action@v3
25+
id: semantic
2526
with:
2627
release_name: gsmlg
2728
working-directory: 'elixir/gsmlg_umbrella'
2829
env:
2930
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3031
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
-
33+
name: Set up QEMU
34+
uses: docker/setup-qemu-action@v1
35+
-
36+
name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v1
38+
-
39+
name: Login to DockerHub
40+
uses: docker/login-action@v1
41+
with:
42+
username: ${{ secrets.DOCKERHUB_USER }}
43+
password: ${{ secrets.DOCKERHUB_PASSWD }}
44+
-
45+
name: Build and push
46+
uses: docker/build-push-action@v2
47+
with:
48+
context: elixir/gsmlg_umbrella
49+
file: elixir/gsmlg_umbrella/Dockerfile
50+
platforms: linux/amd64,linux/arm64/v8
51+
push: true
52+
build-args: |
53+
ELIXIR_VERSION=${{ steps.semantic.outputs.new_release_version }}
54+
tags: |
55+
docker.io/gsmlg/gsmlg.org:v${{ steps.semantic.outputs.new_release_version }}
56+
docker.io/gsmlg/gsmlg.org:latest
57+
3158

elixir/gsmlg_umbrella/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM gsmlg/phoenix:alpine AS builder
2+
3+
ARG MIX_ENV=prod
4+
ARG NAME=gsmlg
5+
ARG RELEASE_VERSION=0.1.0
6+
7+
COPY . /build
8+
9+
WORKDIR /build
10+
11+
RUN apk update && apk add curl jq \
12+
&& mix do deps.get, compile \
13+
&& cd apps/gsmlg_web && mix assets.deploy && cd ../.. \
14+
&& curl -Lf $(npm info --json $package | jq -r .dist.tarball) -o website.tgz \
15+
&& tar xzf website.tgz --strip-components=2 -C apps/gsmlg_web/priv/static \
16+
&& mix distillery.release --env=prod \
17+
&& mkdir /app \
18+
&& tar zxvf "$(find _build/prod/rel -name gsmlg_umbrella.tar.gz)" -C /app \
19+
&& rm -rf /var/cache/apk/*
20+
21+
FROM alpine:3.14
22+
23+
ARG RELEASE_VERSION=0.1.0
24+
25+
LABEL maintainer="GSMLG <gsmlg.com@gmail.com>"
26+
LABEL RELEASE_VERSION="${RELEASE_VERSION}"
27+
28+
ENV PORT=80 \
29+
REPLACE_OS_VARS=true \
30+
ERL_EPMD_PORT=4369 \
31+
POD_IP=127.0.0.1 \
32+
ERLCOOKIE=erlang_cookie \
33+
DATABASE_URL=ecto://USER:PASS@HOST/DATABASE \
34+
POOL_SIZE=10 \
35+
SECRET_KEY_BASE=gsmlg_umbrella
36+
37+
RUN apk update \
38+
&& apk add openssl \
39+
&& rm -rf /var/cache/apk/*
40+
41+
COPY --from=builder /app /app
42+
43+
EXPOSE 80 4369
44+
45+
ENTRYPOINT ["/app/bin/gsmlg", "foreground"]

elixir/gsmlg_umbrella/config/runtime.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ if config_env() == :prod do
4141
# If you are doing OTP releases, you need to instruct Phoenix
4242
# to start each relevant endpoint:
4343
#
44-
# config :gsmlg_web, GSMLGWeb.Endpoint, server: true
45-
#
44+
config :gsmlg_web, GSMLGWeb.Endpoint, server: true
45+
4646
# Then you can assemble a release by calling `mix release`.
4747
# See `mix help release` for more information.
4848

elixir/gsmlg_umbrella/rel/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
# will be used by default
4848

4949
release :gsmlg_umbrella do
50-
set version: current_version(:gsmlg_umbrella)
50+
set version: System.get_env("RELEASE_VERSION", current_version(:gsmlg_web))
5151
set applications: [
5252
:runtime_tools,
5353
gsmlg: :permanent,

0 commit comments

Comments
 (0)