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 ./src ./src
|
||||
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
||||
make dev && \
|
||||
ldd bin/backend | tr -s '[:blank:]' '\n' | grep '^/' | \
|
||||
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \
|
||||
make dev; \
|
||||
else \
|
||||
make; \
|
||||
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
|
||||
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=builder /usr/src/mentorenwahl/db ./db
|
||||
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
|
||||
CMD [ "./bin/backend", "run" ]
|
||||
|
|
|
@ -23,8 +23,10 @@ authors:
|
|||
license: GPL-3.0
|
||||
|
||||
targets:
|
||||
backend:
|
||||
main: src/backend.cr
|
||||
api:
|
||||
main: src/bin/api.cr
|
||||
worker:
|
||||
main: src/bin/worker.cr
|
||||
|
||||
crystal: 1.7.2
|
||||
|
||||
|
|
|
@ -23,6 +23,4 @@ require "./backend/*"
|
|||
module Backend
|
||||
Docker.setup
|
||||
Db.init
|
||||
|
||||
Commander.run(CLI, ARGV)
|
||||
end
|
||||
|
|
|
@ -3,10 +3,10 @@ require "tallboy"
|
|||
require "wannabe_bool"
|
||||
require "fancyline"
|
||||
|
||||
module Backend
|
||||
CLI = Commander::Command.new do |cmd|
|
||||
cmd.use = "backend"
|
||||
cmd.short = "Mentorenwahl backend CLI"
|
||||
module Backend::Cli
|
||||
API = Commander::Command.new do |cmd|
|
||||
cmd.use = "api"
|
||||
cmd.short = "Mentorenwahl backend API CLI"
|
||||
|
||||
cmd.run do
|
||||
puts cmd.help
|
||||
|
@ -287,4 +287,23 @@ module Backend
|
|||
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
|
||||
|
|
|
@ -29,7 +29,7 @@ module Backend
|
|||
[
|
||||
Service::SynchronousStarter.new([
|
||||
Web::Service.new.as(Service),
|
||||
Worker::Service.new.as(Service),
|
||||
# Worker::Service.new.as(Service),
|
||||
] of Service).as(Service::Starter),
|
||||
]
|
||||
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 {
|
||||
proxy_pass http://backend/;
|
||||
proxy_pass http://api/;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,33 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# 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"
|
||||
|
||||
services:
|
||||
|
@ -27,7 +54,7 @@ services:
|
|||
- 8080:8080
|
||||
depends_on:
|
||||
- adminer
|
||||
- backend
|
||||
- api
|
||||
- frontend
|
||||
|
||||
db:
|
||||
|
@ -66,31 +93,20 @@ services:
|
|||
volumes:
|
||||
- ./data/static:/static
|
||||
|
||||
backend:
|
||||
image: git.dergrimm.net/mentorenwahl/backend:latest
|
||||
build:
|
||||
context: ./backend
|
||||
args:
|
||||
BUILD_ENV: production
|
||||
restart: always
|
||||
worker:
|
||||
<<: *backend
|
||||
command: ./bin/worker run
|
||||
deploy:
|
||||
replicas: 2
|
||||
|
||||
api:
|
||||
<<: *backend
|
||||
command: ./bin/api run
|
||||
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
|
||||
- worker
|
||||
|
||||
frontend:
|
||||
image: git.dergrimm.net/mentorenwahl/frontend:latest
|
||||
|
@ -98,7 +114,7 @@ services:
|
|||
context: ./frontend
|
||||
restart: always
|
||||
depends_on:
|
||||
- backend
|
||||
- api
|
||||
|
||||
volumes:
|
||||
db:
|
||||
|
|
Loading…
Reference in New Issue