feat: Docker file

This commit is contained in:
П$iх 2022-08-03 23:17:49 +03:00
parent 4c73ed54c5
commit 5023d75fcd
5 changed files with 23 additions and 16 deletions

View File

@ -14,7 +14,7 @@
/docker-compose.yml /docker-compose.yml
/docker-compose-services.yml /docker-compose-services.yml
# tools # utilities
/.gitlab-ci.yml /.gitlab-ci.yml
/.golangci.yaml /.golangci.yaml

View File

@ -1,4 +1,4 @@
TOKEN= TOKEN=
OWNER= OWNER=
# some application assets # some application assets
# DOCS_PATH=docs # MIGRATION_PARAM=/migrations

View File

@ -16,29 +16,41 @@ RUN go mod download
# Copy the code into the container # Copy the code into the container
COPY . . COPY . .
# Some different way for vendoring
#RUN go mod tidy && go mod vendor
# Build the application # Build the application
RUN go build -o build/app . RUN go build -ldflags "-s -w" -o /build/app .
FROM scratch 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 # Move to /app directory as the place for resulting binary folder
WORKDIR / WORKDIR /
# Copy binary from build to main folder # Copy binary from build to main folder
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ 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 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 #COPY ./database/data.json /database/data.json
# Export necessary port # Export necessary port
#EXPOSE 3000 #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 # Command to run when starting the container
#CMD ["/app"] CMD ["/app"]
# if have not application daemon # if have not application daemon
#CMD tail -f /dev/null #CMD tail -f /dev/null

View File

@ -9,12 +9,7 @@ docker push psssix/golang-app:latest
``` ```
#### Run docker container #### Run docker container
Run container on localhost docker Run container on docker
```bash ```bash
docker run -d --env-file .env.docker --name study-bot psssix/golang-app docker run -d --env-file .env.docker --name golang-app psssix/golang-app:latest
```
Run container on overcast docker
```bash
docker pull psssix/golang-app
docker run -d --env-file .env --name golang-app psssix/golang-app:latest
``` ```

View File

@ -25,7 +25,7 @@ loadVariable() {
setupEnvironment() { setupEnvironment() {
loadVariable 'TIMEZONE' 'Etc/GMT' loadVariable 'TIMEZONE' 'Etc/GMT'
# loadVariable 'MIGRATION_PATH' '' # loadVariable 'MIGRATION_PARAM' ''
# # initialize values that might be stored in a file # # initialize values that might be stored in a file
# loadVariable 'MYSQL_HOST' # loadVariable 'MYSQL_HOST'
# loadVariable 'MYSQL_DATABASE' 'defaultDatabase' # loadVariable 'MYSQL_DATABASE' 'defaultDatabase'