Update
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
735c91f7b4
commit
4f6d30dc4b
4
Makefile
4
Makefile
|
@ -19,10 +19,10 @@
|
|||
all: prod
|
||||
|
||||
dev:
|
||||
docker compose build --build-arg BUILD_ENV=development
|
||||
BUILDKIT_PROGRESS=plain docker compose build --build-arg BUILD_ENV=development
|
||||
|
||||
prod:
|
||||
docker compose build
|
||||
BUILDKIT_PROGRESS=plain docker compose build
|
||||
|
||||
docs:
|
||||
cd docs && mdbook build
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
FROM docker.io/crystallang/crystal:1.6.2-alpine as crystal
|
||||
FROM tdewolff/minify:latest as minify
|
||||
|
||||
FROM crystal as micrate-deps
|
||||
WORKDIR /usr/src/micrate
|
||||
|
@ -28,7 +29,7 @@ COPY --from=micrate-deps /usr/src/micrate/lib ./lib
|
|||
COPY ./micrate/src ./src
|
||||
RUN shards build --release --static --verbose -s -p -t
|
||||
|
||||
FROM tdewolff/minify as public
|
||||
FROM minify as public
|
||||
WORKDIR /usr/src/public
|
||||
COPY ./public ./src
|
||||
RUN minify -r -o ./dist ./src
|
||||
|
@ -38,6 +39,13 @@ WORKDIR /usr/src/mentorenwahl
|
|||
COPY ./shard.yml ./shard.lock ./
|
||||
RUN shards install --production
|
||||
|
||||
FROM minify as templates-html
|
||||
WORKDIR /usr/src/templates/html
|
||||
COPY ./templates/html .
|
||||
RUN find . -name "*.html.ecr" -type f | xargs -I % sh -c 'mv "%" "$(basename -s .html.ecr "%").min.html"'
|
||||
RUN minify . -r -o .
|
||||
RUN find . -name "*.min.html" -type f | xargs -I % sh -c 'mv "%" "%.ecr"'
|
||||
|
||||
FROM crystal as builder
|
||||
WORKDIR /usr/src/mentorenwahl
|
||||
RUN apk add --no-cache pcre2-dev
|
||||
|
@ -49,6 +57,7 @@ COPY ./Makefile .
|
|||
COPY ./LICENSE .
|
||||
COPY ./db ./db
|
||||
COPY --from=public /usr/src/public/dist ./public
|
||||
COPY --from=templates-html /usr/src/templates/html ./templates/html
|
||||
COPY ./src ./src
|
||||
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
||||
make dev; \
|
||||
|
|
|
@ -42,7 +42,11 @@ module Backend::Auth
|
|||
end
|
||||
|
||||
def generate_pdf(html : String) : GeneratePdfResponse
|
||||
resp = HTTP::Client.post(Path[Backend.config.auth.url, "pdf"].to_s, body: {:html => html}.to_json)
|
||||
resp = HTTP::Client.post(
|
||||
Path[Backend.config.auth.url, "pdf"].to_s,
|
||||
headers: HTTP::Headers{"Content-Type" => "application/json"},
|
||||
body: {:html => html}.to_json
|
||||
)
|
||||
data = GeneratePdfResponse.from_json(resp.body)
|
||||
raise "Error in response (#{resp.status_code}): #{data.error}" if resp.status_code != 201
|
||||
|
||||
|
|
|
@ -120,50 +120,16 @@ module Backend
|
|||
end
|
||||
)
|
||||
|
||||
html = Templates::Users.new(students, teachers).to_s
|
||||
html = Templates::Users.new(
|
||||
Time.local,
|
||||
users.classes.map { |cl| {cl.name, cl.students.size} },
|
||||
students,
|
||||
teachers
|
||||
).to_s
|
||||
puts "Filepath: #{Auth.generate_pdf(html).filename}"
|
||||
end
|
||||
end
|
||||
|
||||
# cmd.commands.add do |c|
|
||||
# c.use = "register <username> <role>"
|
||||
# c.short = "Seeds the database with required data"
|
||||
# c.long = c.short
|
||||
|
||||
# c.flags.add do |f|
|
||||
# f.name = "admin"
|
||||
# f.long = "--admin"
|
||||
# f.default = false
|
||||
# f.description = "Register as admin"
|
||||
# end
|
||||
|
||||
# c.flags.add do |f|
|
||||
# f.name = "yes"
|
||||
# f.short = "-y"
|
||||
# f.long = "--yes"
|
||||
# f.default = false
|
||||
# f.description = "Answer yes to all questions"
|
||||
# end
|
||||
|
||||
# c.run do |opts, args|
|
||||
# username = args[0]
|
||||
# role = Db::UserRole.from_string(args[1].underscore)
|
||||
# unless opts.bool["yes"]
|
||||
# print "Register '#{username}' as '#{role.to_api}'#{opts.bool["admin"] ? " with admin privileges" : nil}? [y/N] "
|
||||
# abort unless gets(chomp: true).not_nil!.strip.downcase == "y"
|
||||
# end
|
||||
|
||||
# user = Db::User.create!(username: username, role: role.to_s, admin: opts.bool["admin"])
|
||||
# if role == Db::UserRole::Student
|
||||
# Db::Student.create!(user_id: user.id)
|
||||
# end
|
||||
|
||||
# # Worker::Jobs::CacheLdapUserJob.new(user.id).enqueue
|
||||
|
||||
# puts "Done!"
|
||||
# end
|
||||
# end
|
||||
|
||||
# ameba:disable Lint/ShadowingOuterLocalVar
|
||||
cmd.commands.add do |cmd|
|
||||
cmd.use = "user:list"
|
||||
|
|
|
@ -22,8 +22,13 @@ class Backend::Templates::Users
|
|||
end
|
||||
end
|
||||
|
||||
def initialize(@students : Array(Student), @teachers : Array(User))
|
||||
def initialize(
|
||||
@time : Time,
|
||||
@classes : Array({String, Int32}),
|
||||
@students : Array(Student),
|
||||
@teachers : Array(User)
|
||||
)
|
||||
end
|
||||
|
||||
ECR.def_to_s "#{__DIR__}/users.ecr"
|
||||
ECR.def_to_s "templates/html/users.min.html.ecr"
|
||||
end
|
||||
|
|
|
@ -66,7 +66,7 @@ module Backend
|
|||
ATH::StreamedResponse.new(
|
||||
headers: HTTP::Headers{
|
||||
"content-type" => "application/json",
|
||||
"cache-control" => {"no-cache", "no-store", "max-age=0", "must-revalidate"},
|
||||
"cache-control" => ["no-cache", "no-store", "max-age=0", "must-revalidate"],
|
||||
}
|
||||
) do |io|
|
||||
Api::Schema::SCHEMA.execute(
|
||||
|
|
|
@ -6,10 +6,14 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Benutzeraccounts | Mentorenwahl</title>
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Fira+Code&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
font-family: monospace;
|
||||
font-family: "Fira Code", monospace;
|
||||
}
|
||||
|
||||
.column {
|
||||
|
@ -34,18 +38,79 @@
|
|||
}
|
||||
|
||||
code {
|
||||
font-family: monospace;
|
||||
font-family: "Fira Code", monospace;
|
||||
background: #f4f4f4;
|
||||
word-wrap: break-word;
|
||||
box-decoration-break: clone;
|
||||
padding: 0.1rem 0.3rem 0.2rem;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.dashed {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
ul.dashed > li {
|
||||
text-indent: -5px;
|
||||
}
|
||||
|
||||
ul.dashed > li:before {
|
||||
content: "-";
|
||||
text-indent: -5px;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: none;
|
||||
height: 1px;
|
||||
background: black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p>Schüler:</p>
|
||||
<h1>Mentorenwahl: Benutzerexport</h1>
|
||||
<table width="100%" cellspacing="0" border="0">
|
||||
<colgroup>
|
||||
<col width="25%" />
|
||||
<col width="75%" />
|
||||
</colgroup>
|
||||
|
||||
<tr>
|
||||
<th class="border">Zeitpunkt</th>
|
||||
<%- time_unix = @time.to_unix -%>
|
||||
<td class="border padded"><%= @time %> (<%= time_unix.negative? ? "-" : "+" %><%= time_unix %>)</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="border">Anzahl Schüler</th>
|
||||
<td class="border padded"><%= @students.size %></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="border">Klassen</th>
|
||||
<td class="border padded">
|
||||
<ul class="dashed">
|
||||
<%- @classes.each do |cl| -%>
|
||||
<li><%= cl[0] %> (<%= cl[1] %>)</li>
|
||||
<%- end -%>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="border">Anzahl Lehrer</th>
|
||||
<td class="border padded"><%= @teachers.size %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Schüler:</h2>
|
||||
<table width="100%" cellspacing="0" border="0">
|
||||
<colgroup>
|
||||
<col class="column" />
|
||||
|
@ -57,8 +122,8 @@
|
|||
<%- @students.in_groups_of(4).each do |group| -%>
|
||||
<tr>
|
||||
<%- group.each do |student| %>
|
||||
<td class="border padded">
|
||||
<%- if student -%>
|
||||
<%- if student -%>
|
||||
<td class="border padded">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -78,8 +143,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<%- end -%>
|
||||
</td>
|
||||
</td>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
</tr>
|
||||
<%- end -%>
|
||||
|
@ -88,7 +153,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<p>Lehrer:</p>
|
||||
<h2>Lehrer:</h2>
|
||||
<table width="100%" cellspacing="0" border="0">
|
||||
<colgroup>
|
||||
<col class="column" />
|
||||
|
@ -100,8 +165,8 @@
|
|||
<%- @teachers.in_groups_of(4).each do |group| -%>
|
||||
<tr>
|
||||
<%- group.each do |teacher| %>
|
||||
<td class="border padded">
|
||||
<%- if teacher -%>
|
||||
<%- if teacher -%>
|
||||
<td class="border padded">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -121,8 +186,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<%- end -%>
|
||||
</td>
|
||||
</td>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
</tr>
|
||||
<%- end -%>
|
|
@ -99,6 +99,8 @@ services:
|
|||
BACKEND_LDAP_BIND_PASSWORD: ${BACKEND_LDAP_BIND_PASSWORD}
|
||||
BACKEND_LDAP_CACHE_REFRESH_INTERVAL: ${BACKEND_LDAP_CACHE_REFRESH_INTERVAL}
|
||||
BACKEND_AUTH_URL: "http://auth/v1"
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
|
||||
frontend:
|
||||
image: git.dergrimm.net/mentorenwahl/frontend:latest
|
||||
|
|
Loading…
Reference in New Issue