Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Personal Server Community
Gaja
Commits
464810da
Commit
464810da
authored
Jun 06, 2019
by
Frank
👽
Browse files
Add docker build files
parent
f643e0ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
4 deletions
+90
-4
Dockerfile
Dockerfile
+54
-0
Makefile
Makefile
+21
-0
config/docker.env
config/docker.env
+10
-0
config/prod.secret.exs
config/prod.secret.exs
+5
-4
No files found.
Dockerfile
0 → 100644
View file @
464810da
ARG
ALPINE_VERSION=3.8
FROM
elixir:1.7.2-alpine AS builder
ARG
APP_NAME
ARG
APP_VSN
ARG
MIX_ENV
ARG
PHOENIX_SUBDIR=.
ENV
APP_NAME=${APP_NAME} \
APP_VSN=${APP_VSN} \
MIX_ENV=${MIX_ENV}
# By convention, /opt is typically used for applications
WORKDIR
/opt/gaja
# This step installs all the build tools we'll need
RUN
apk update
&&
\
apk upgrade
--no-cache
&&
\
apk add
--no-cache
\
git
\
build-base
&&
\
mix local.rebar
--force
&&
\
mix local.hex
--force
RUN
git clone
--single-branch
--depth
1 https://gitlab.com/personal-server-community/personal-database.git /opt/gaja
RUN
mix
do
deps.get, deps.compile, compile
RUN
\
mkdir
-p
/opt/built
&&
\
mix release
--verbose
&&
\
cp
_build/
${
MIX_ENV
}
/rel/
${
APP_NAME
}
/releases/
${
APP_VSN
}
/
${
APP_NAME
}
.tar.gz /opt/built
&&
\
cd
/opt/built
&&
\
tar
-xzf
${
APP_NAME
}
.tar.gz
&&
\
rm
${
APP_NAME
}
.tar.gz
FROM
alpine:${ALPINE_VERSION}
ARG
APP_NAME=gaja
RUN
apk update
&&
\
apk add
--no-cache
\
bash
\
openssl-dev
ENV
REPLACE_OS_VARS=true \
APP_NAME=${APP_NAME}
WORKDIR
/opt/gaja
COPY
--from=builder /opt/built .
CMD
trap 'exit' INT; /opt/gaja/bin/${APP_NAME} foreground
Makefile
0 → 100644
View file @
464810da
.PHONY
:
help
APP_NAME
?=
`
grep
'app:'
mix.exs |
sed
-e
's/\[//g'
-e
's/ //g'
-e
's/app://'
-e
's/[:,]//g'
`
APP_VSN
?=
`
grep
'version:'
mix.exs |
cut
-d
'"'
-f2
`
BUILD
?=
`
git rev-parse
--short
HEAD
`
help
:
@
echo
"
$(APP_NAME)
:
$(APP_VSN)
-
$(BUILD)
"
@
perl
-nle
'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}'
$(MAKEFILE_LIST)
|
sort
|
awk
'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build
:
##
Build the Docker image
docker build
--build-arg
APP_NAME
=
$(APP_NAME)
\
--build-arg
APP_VSN
=
$(APP_VSN)
\
--build-arg
MIX_ENV
=
prod
\
-t
$(APP_NAME)
:
$(APP_VSN)
-
$(BUILD)
\
-t
$(APP_NAME)
:latest .
run
:
##
Run the app in Docker
docker run
--env-file
config/docker.env
\
--expose
4000
-p
4000:4000
\
--rm
-it
$(APP_NAME)
:latest
config/docker.env
0 → 100644
View file @
464810da
HOSTNAME=localhost
SECRET_KEY_BASE="u1QXlca4XEZKb1o3HL/aUlznI1qstCNAQ6yme/lFbFIs0Iqiq/annZ+Ty8JyUCDc"
DATABASE_HOST=db
DATABASE_USER=postgres
DATABASE_PASS=postgres
DATABASE_NAME=myapp_db
PORT=4000
LANG=en_US.UTF-8
REPLACE_OS_VARS=true
ERLANG_COOKIE=gaja
config/prod.secret.exs
View file @
464810da
...
...
@@ -9,12 +9,13 @@ use Mix.Config
# kept out of version control and might be hard to recover
# or recreate for your teammates (or yourself later on).
config
:gaja
,
Gaja
.
Endpoint
,
secret_key_base:
"80uFIZUtGYfo69S+zieHRQHb1IJrFFyXlq5jzjHsh3ypk3Q1PCNZNrmTVg83eYhZ"
secret_key_base:
System
.
get_env
(
"SECRET_KEY_BASE"
)
# Configure your database
config
:gaja
,
Gaja
.
Repo
,
adapter:
Ecto
.
Adapters
.
Postgres
,
username:
"postgres"
,
password:
"postgres"
,
database:
"gaja_prod"
,
username:
System
.
get_env
(
"DATABASE_USER"
),
password:
System
.
get_env
(
"DATABASE_PASS"
),
database:
System
.
get_env
(
"DATABASE_NAME"
),
hostname:
System
.
get_env
(
"DATABASE_HOST"
),
pool_size:
15
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment