diff --git a/.dockerignore b/.dockerignore index 1e21915..fc23a21 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ /docker-compose.yml /docker-compose-services.yml -# tools +# utilities /.gitlab-ci.yml /.golangci.yaml diff --git a/.env.dist b/.env.dist index 30028a9..95848bd 100644 --- a/.env.dist +++ b/.env.dist @@ -1,4 +1,4 @@ TOKEN= OWNER= # some application assets -# DOCS_PATH=docs \ No newline at end of file +# MIGRATION_PARAM=/migrations \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3970996..3d0c9a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,29 +16,41 @@ RUN go mod download # Copy the code into the container COPY . . -# Some different way for vendoring -#RUN go mod tidy && go mod vendor # Build the application -RUN go build -o build/app . +RUN go build -ldflags "-s -w" -o /build/app . FROM scratch +# or alpine, if you need install utilities +# +#FROM alpine:latest +# +## Add entrypoint dependency +#RUN apk add --no-cache bash mysql-client mariadb-connector-c + # Move to /app directory as the place for resulting binary folder WORKDIR / # Copy binary from build to main folder COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /source/build/app app +COPY --from=builder /build/app app # Copy some application assets +#COPY --from=builder /source/docker/environment.sh ./docker/environment.sh +#COPY --from=builder /source/docker/logging.sh ./docker/logging.sh +#COPY --from=builder /source/entrypoint.sh . +#COPY --from=builder /source/migrations ./migrations #COPY ./database/data.json /database/data.json + # Export necessary port #EXPOSE 3000 -ENTRYPOINT ["/app"] +# entry and start entrypoint with some actions and checks before CMD +#ENTRYPOINT ["bash", "/entrypoint.sh" ] # Command to run when starting the container -#CMD ["/app"] +CMD ["/app"] + # if have not application daemon #CMD tail -f /dev/null \ No newline at end of file diff --git a/README.md b/README.md index 267fe46..d4cac33 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,7 @@ docker push psssix/golang-app:latest ``` #### Run docker container -Run container on localhost docker +Run container on docker ```bash - docker run -d --env-file .env.docker --name study-bot psssix/golang-app -``` -Run container on overcast docker -```bash -docker pull psssix/golang-app -docker run -d --env-file .env --name golang-app psssix/golang-app:latest +docker run -d --env-file .env.docker --name golang-app psssix/golang-app:latest ``` \ No newline at end of file diff --git a/deploy/docker/environment.sh b/deploy/docker/environment.sh index 3fd7008..518f241 100644 --- a/deploy/docker/environment.sh +++ b/deploy/docker/environment.sh @@ -25,7 +25,7 @@ loadVariable() { setupEnvironment() { loadVariable 'TIMEZONE' 'Etc/GMT' -# loadVariable 'MIGRATION_PATH' '' +# loadVariable 'MIGRATION_PARAM' '' # # initialize values that might be stored in a file # loadVariable 'MYSQL_HOST' # loadVariable 'MYSQL_DATABASE' 'defaultDatabase'