Update
This commit is contained in:
parent
e7b370b40f
commit
e218a8762c
|
@ -60,12 +60,16 @@ COPY --from=public /usr/src/public/dist ./public
|
||||||
COPY --from=templates-html /usr/src/templates/html ./templates/html
|
COPY --from=templates-html /usr/src/templates/html ./templates/html
|
||||||
COPY ./src ./src
|
COPY ./src ./src
|
||||||
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
||||||
make dev && \
|
make dev; \
|
||||||
ldd bin/backend | tr -s '[:blank:]' '\n' | grep '^/' | \
|
|
||||||
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
|
||||||
else \
|
else \
|
||||||
make; \
|
make; \
|
||||||
fi
|
fi
|
||||||
|
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
||||||
|
ldd bin/api | tr -s '[:blank:]' '\n' | grep '^/' | \
|
||||||
|
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
||||||
|
ldd bin/worker | tr -s '[:blank:]' '\n' | grep '^/' | \
|
||||||
|
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
||||||
|
fi
|
||||||
|
|
||||||
FROM busybox as runner
|
FROM busybox as runner
|
||||||
LABEL maintainer="Dominic Grimm <dominic@dergrimm.net>" \
|
LABEL maintainer="Dominic Grimm <dominic@dergrimm.net>" \
|
||||||
|
@ -77,6 +81,5 @@ WORKDIR /usr/src/mentorenwahl
|
||||||
COPY --from=micrate-builder /usr/src/micrate/bin/micrate ./bin/micrate
|
COPY --from=micrate-builder /usr/src/micrate/bin/micrate ./bin/micrate
|
||||||
COPY --from=builder /usr/src/mentorenwahl/db ./db
|
COPY --from=builder /usr/src/mentorenwahl/db ./db
|
||||||
COPY --from=builder /usr/src/mentorenwahl/deps /
|
COPY --from=builder /usr/src/mentorenwahl/deps /
|
||||||
COPY --from=builder /usr/src/mentorenwahl/bin/backend ./bin/backend
|
COPY --from=builder /usr/src/mentorenwahl/bin ./bin
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD [ "./bin/backend", "run" ]
|
|
||||||
|
|
|
@ -23,8 +23,10 @@ authors:
|
||||||
license: GPL-3.0
|
license: GPL-3.0
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
backend:
|
api:
|
||||||
main: src/backend.cr
|
main: src/bin/api.cr
|
||||||
|
worker:
|
||||||
|
main: src/bin/worker.cr
|
||||||
|
|
||||||
crystal: 1.7.2
|
crystal: 1.7.2
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,4 @@ require "./backend/*"
|
||||||
module Backend
|
module Backend
|
||||||
Docker.setup
|
Docker.setup
|
||||||
Db.init
|
Db.init
|
||||||
|
|
||||||
Commander.run(CLI, ARGV)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,10 @@ require "tallboy"
|
||||||
require "wannabe_bool"
|
require "wannabe_bool"
|
||||||
require "fancyline"
|
require "fancyline"
|
||||||
|
|
||||||
module Backend
|
module Backend::Cli
|
||||||
CLI = Commander::Command.new do |cmd|
|
API = Commander::Command.new do |cmd|
|
||||||
cmd.use = "backend"
|
cmd.use = "api"
|
||||||
cmd.short = "Mentorenwahl backend CLI"
|
cmd.short = "Mentorenwahl backend API CLI"
|
||||||
|
|
||||||
cmd.run do
|
cmd.run do
|
||||||
puts cmd.help
|
puts cmd.help
|
||||||
|
@ -287,4 +287,23 @@ module Backend
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
WORKER = Commander::Command.new do |cmd|
|
||||||
|
cmd.use = "worker"
|
||||||
|
cmd.short = "Mentorenwahl backend worker CLI"
|
||||||
|
|
||||||
|
cmd.run do
|
||||||
|
puts cmd.help
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd.commands.add do |c|
|
||||||
|
c.use = "run"
|
||||||
|
c.short = "Start the worker"
|
||||||
|
c.long = c.short
|
||||||
|
|
||||||
|
c.run do
|
||||||
|
Mosquito::Runner.start
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Backend
|
||||||
[
|
[
|
||||||
Service::SynchronousStarter.new([
|
Service::SynchronousStarter.new([
|
||||||
Web::Service.new.as(Service),
|
Web::Service.new.as(Service),
|
||||||
Worker::Service.new.as(Service),
|
# Worker::Service.new.as(Service),
|
||||||
] of Service).as(Service::Starter),
|
] of Service).as(Service::Starter),
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
require "../backend"
|
||||||
|
|
||||||
|
Commander.run(Backend::Cli::API, ARGV)
|
|
@ -0,0 +1,3 @@
|
||||||
|
require "../backend"
|
||||||
|
|
||||||
|
Commander.run(Backend::Cli::WORKER, ARGV)
|
|
@ -30,7 +30,7 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location /graphql {
|
location /graphql {
|
||||||
proxy_pass http://backend/;
|
proxy_pass http://api/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,33 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
x-backend:
|
||||||
|
&backend
|
||||||
|
image: git.dergrimm.net/mentorenwahl/backend:latest
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
args:
|
||||||
|
BUILD_ENV: production
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
- auth
|
||||||
|
environment:
|
||||||
|
BACKEND_MINIMUM_TEACHER_SELECTION_COUNT: ${BACKEND_MINIMUM_TEACHER_SELECTION_COUNT}
|
||||||
|
BACKEND_ASSIGNMENT_RUN_TIME: ${BACKEND_ASSIGNMENT_RUN_TIME}
|
||||||
|
BACKEND_API_JWT_SECRET: ${BACKEND_API_JWT_SECRET}
|
||||||
|
BACKEND_API_JWT_EXPIRATION: ${BACKEND_API_JWT_EXPIRATION}
|
||||||
|
BACKEND_DB_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_USER}
|
||||||
|
BACKEND_DB_ALLOW_OLD_SCHEMA: ${BACKEND_DB_ALLOW_OLD_SCHEMA}
|
||||||
|
BACKEND_REDIS_HOST: redis
|
||||||
|
BACKEND_REDIS_PORT: 6379
|
||||||
|
BACKEND_AUTH_URL: "http://auth/v1"
|
||||||
|
volumes:
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
- ./data/static:/static
|
||||||
|
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
@ -27,7 +54,7 @@ services:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- adminer
|
- adminer
|
||||||
- backend
|
- api
|
||||||
- frontend
|
- frontend
|
||||||
|
|
||||||
db:
|
db:
|
||||||
|
@ -66,31 +93,20 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/static:/static
|
- ./data/static:/static
|
||||||
|
|
||||||
backend:
|
worker:
|
||||||
image: git.dergrimm.net/mentorenwahl/backend:latest
|
<<: *backend
|
||||||
build:
|
command: ./bin/worker run
|
||||||
context: ./backend
|
deploy:
|
||||||
args:
|
replicas: 2
|
||||||
BUILD_ENV: production
|
|
||||||
restart: always
|
api:
|
||||||
|
<<: *backend
|
||||||
|
command: ./bin/api run
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- redis
|
- redis
|
||||||
- auth
|
- auth
|
||||||
environment:
|
- worker
|
||||||
BACKEND_MINIMUM_TEACHER_SELECTION_COUNT: ${BACKEND_MINIMUM_TEACHER_SELECTION_COUNT}
|
|
||||||
BACKEND_ASSIGNMENT_RUN_TIME: ${BACKEND_ASSIGNMENT_RUN_TIME}
|
|
||||||
BACKEND_API_JWT_SECRET: ${BACKEND_API_JWT_SECRET}
|
|
||||||
BACKEND_API_JWT_EXPIRATION: ${BACKEND_API_JWT_EXPIRATION}
|
|
||||||
BACKEND_DB_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_USER}
|
|
||||||
BACKEND_DB_ALLOW_OLD_SCHEMA: ${BACKEND_DB_ALLOW_OLD_SCHEMA}
|
|
||||||
BACKEND_REDIS_HOST: redis
|
|
||||||
BACKEND_REDIS_PORT: 6379
|
|
||||||
BACKEND_AUTH_URL: "http://auth/v1"
|
|
||||||
volumes:
|
|
||||||
- /etc/timezone:/etc/timezone:ro
|
|
||||||
- /etc/localtime:/etc/localtime:ro
|
|
||||||
- ./data/static:/static
|
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: git.dergrimm.net/mentorenwahl/frontend:latest
|
image: git.dergrimm.net/mentorenwahl/frontend:latest
|
||||||
|
@ -98,7 +114,7 @@ services:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- api
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db:
|
db:
|
||||||
|
|
Loading…
Reference in New Issue