Browse Source

Added dockerimage

pull/7/head
Victor Roest 2 years ago
parent
commit
348b665dd5
Signed by: 0x76 GPG Key ID: A3923C699D1A3BDA
  1. 13
      .dockerignore
  2. 30
      Dockerfile
  3. 2
      lib/dps/author.ex
  4. 28
      lib/dps_web/templates/poem_page/new.html.eex
  5. 24
      priv/static/css/app.css

13
.dockerignore

@ -0,0 +1,13 @@
_build/
.elixir_ls/
.git/
.vscode/
deps/
k8s/
test/
.dockerignore
.env
.formatter.exs
.gitignore
.travis.yml
Dockerfile

30
Dockerfile

@ -0,0 +1,30 @@
FROM elixir:1.11 AS builder
ENV MIX_ENV=prod
WORKDIR /build/dps
# Download + Compile dependencies
RUN mix local.rebar --force && mix local.hex --force
COPY mix.* .
RUN mix do deps.get, deps.compile
# Compile static assets
COPY config config
COPY priv/static priv/static
RUN mix phx.digest
# Build
COPY . .
RUN mkdir -p /opt/release && \
mix release && \
mv _build/${MIX_ENV}/rel/dps /opt/release
# Runner image
FROM erlang:23-slim AS runner
WORKDIR /app/
COPY --from=builder /opt/release/dps .
CMD ["/app/bin/dps", "start"]

2
lib/dps/author.ex

@ -34,7 +34,7 @@ defmodule Dps.Author.Query do
def all_authors(sort_by \\ [asc: :name]) do
Author
|> order_by(^sort_by)
|> Repo.all()
|> Repo.all
end
def get_author_by_id(id) do

28
lib/dps_web/templates/poem_page/new.html.eex

@ -2,17 +2,29 @@
<%= form_for @changeset, Routes.poem_page_path(@conn, :create), fn f -> %>
<label for="poem_title">Title:</label>
<%= text_input f, :title %>
<div>
<label for="poem_title">Title</label>
<%= text_input f, :title %>
</div>
<label for="poem_epigraph">Epigraph:</label>
<%= text_input f, :epigraph %>
<div>
<label for="poem_epigraph">Epigraph</label>
<%= text_input f, :epigraph %>
</div>
<label for="poem_author_id">Author</label>
<%= select f, :author_id, @authors %>
<div>
<label for="poem_author_id">Author
<span class="deemphasize">
<%= link "add author", to: Routes.author_page_path(@conn, :new) %>
</span>
</label>
<%= select f, :author_id, @authors %>
</div>
<label for="poem_content">Content</label>
<%= textarea f, :content %>
<div>
<label for="poem_content">Content</label>
<%= textarea f, :content %>
</div>
<%= submit "Submit" %>
<% end %>

24
priv/static/css/app.css

@ -100,27 +100,37 @@ pre {
}
/* Forms */
form > label {
form {
width: 50rem;
max-width: 90%;
}
form label {
font-size: 1.2rem;
}
form > input[type=text],
form > select,
form > textarea {
form span.deemphasize {
color: var(--secondary);
opacity: 0.9;
font-size: 1rem;
}
form input[type=text],
form select,
form textarea {
width: 100%;
padding: 1.2em 2em;
margin: 0.5em 0;
display: inline-block;
border: 1px solid var(--border);
border-radius: 4px;
box-sizing: border-box;
}
form > textarea {
form textarea {
height: 35vh;
}
form > button[type="submit"] {
form button[type="submit"] {
width: 100%;
background-color: var(--accent);
color: var(--text-inverted);

Loading…
Cancel
Save