feat: add Dockerfile (#600)

This commit is contained in:
yehong 2023-07-23 22:19:47 +08:00 committed by GitHub
parent b185161aa9
commit b27a9a925d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 11 deletions

View File

@ -151,14 +151,4 @@ jobs:
target: STANDARD
platforms: linux/amd64,linux/arm64
push: true
tags: casbin/casibase:${{steps.get-current-tag.outputs.tag }},casbin/casibase:latest
- name: Push All In One Version to Docker Hub
uses: docker/build-push-action@v3
if: github.repository == 'casbin/casibase' && github.event_name == 'push' && steps.should_push.outputs.push=='true'
with:
context: .
target: ALLINONE
platforms: linux/amd64,linux/arm64
push: true
tags: casbin/casibase-all-in-one:${{steps.get-current-tag.outputs.tag }},casbin/casibase-all-in-one:latest
tags: casbin/casibase:${{steps.get-current-tag.outputs.tag }},casbin/casibase:latest

18
Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM golang:1.19 AS BACK
WORKDIR /go/src/casibase
COPY . .
RUN go build -o server ./main.go
FROM debian:latest AS STANDARD
LABEL MAINTAINER="https://casibase.org/"
ARG TARGETOS
ARG TARGETARCH
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-amd64}"
WORKDIR /
COPY --from=BACK /go/src/casibase/ ./
ENTRYPOINT ["/bin/bash"]
CMD ["/docker-entrypoint.sh"]

8
docker-entrypoint.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ "${MYSQL_ROOT_PASSWORD}" = "" ] ;then MYSQL_ROOT_PASSWORD=123456 ;fi
service mariadb start
mysqladmin -u root password ${MYSQL_ROOT_PASSWORD}
exec /server --createDatabase=true