-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker compose, dockerfiles, Quasar upgrade, initialize and clean up …
…DB after deploy
- Loading branch information
Showing
18 changed files
with
516 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright © 2018-2019 Stanislav Valasek <[email protected]> | ||
version: "3.3" | ||
|
||
services: | ||
server: | ||
build: | ||
context: . | ||
dockerfile: ./dockerfiles/cloud/Dockerfile | ||
sysctls: | ||
- net.ipv6.conf.all.disable_ipv6=1 | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- "db" | ||
db: | ||
image: postgres | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: timesheet | ||
POSTGRES_USER: timesheet | ||
POSTGRES_DB: timesheet | ||
ports: | ||
- "5432:5432" | ||
# sudo docker run --name pg-docker -e POSTGRES_USER=timesheet -e POSTGRES_PASSWORD=timesheet -e POSTGRES_DB=timesheet -d -p 5432:5432 postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright © 2018-2019 Stanislav Valasek <[email protected]> | ||
version: "3.3" | ||
|
||
services: | ||
server: | ||
build: | ||
context: . | ||
dockerfile: ./dockerfiles/dataarch/Dockerfile | ||
sysctls: | ||
- net.ipv6.conf.all.disable_ipv6=1 | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- "db" | ||
db: | ||
image: postgres | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: timesheet | ||
POSTGRES_USER: timesheet | ||
POSTGRES_DB: timesheet | ||
ports: | ||
- "5432:5432" | ||
# sudo docker run --name pg-docker -e POSTGRES_USER=timesheet -e POSTGRES_PASSWORD=timesheet -e POSTGRES_DB=timesheet -d -p 5432:5432 postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Copyright © 2018-2019 Stanislav Valasek <[email protected]> | ||
|
||
# Accept the Go version for the image to be set as a build argument. | ||
# Default to Go 1.13 | ||
ARG GO_VERSION=1.13 | ||
|
||
########################################### | ||
# First stage: build the backend executable. | ||
# FROM golang:${GO_VERSION}-alpine AS builder | ||
FROM golang:alpine AS backend | ||
|
||
# Create the user and group files that will be used in the running container to | ||
# run the process as an unprivileged user. | ||
RUN mkdir /user && \ | ||
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \ | ||
echo 'nobody:x:65534:' > /user/group | ||
|
||
# Install the Certificate-Authority certificates for the app to be able to make | ||
# calls to HTTPS endpoints. | ||
# Git is required for fetching the dependencies. | ||
RUN apk add --no-cache ca-certificates git | ||
|
||
# Set the working directory outside $GOPATH to enable the support for modules. | ||
WORKDIR /src | ||
|
||
# Fetch dependencies first; they are less susceptible to change on every build | ||
# and will therefore be cached for speeding up the next build | ||
COPY ./server/go.mod ./go.mod | ||
RUN go mod download | ||
ADD ./server/data/ /data | ||
RUN chmod -R ug+rw /data | ||
ADD ./server/documentation/ /documentation | ||
ADD ./server/documentation/ /documentation/statics | ||
RUN chmod -R ug+rw /documentation | ||
ADD ./server/logs/ /logs | ||
RUN chmod -R ug+rwx /logs | ||
COPY ./docker-entrypoint.sh /docker-entrypoint.sh | ||
# COPY ./server/timesheet-dev.yaml /timesheet.yaml | ||
COPY ./server/timesheet-dataarch.yaml /timesheet.yaml | ||
# COPY ./server/timesheet-cloud.yaml /timesheet.yaml | ||
RUN chmod +x /docker-entrypoint.sh | ||
|
||
# Import the code from the context. | ||
COPY ./server/ ./ | ||
|
||
# Build the executable to `/app`. Mark the build as statically linked. | ||
# RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" CGO_ENABLED=0 \ | ||
# -installsuffix 'static' \ | ||
# -o /app . | ||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \ | ||
-ldflags "-X github.com/valasek/timesheet/server/version.Version=1.4.4" \ | ||
-installsuffix 'static' -o /timesheet.bin . | ||
# RUN ls -la . | ||
|
||
############################################## | ||
# Second stage: build the frontend executable. | ||
FROM node:lts-alpine AS frontend | ||
# fix due to optipng-bin in icon-factory - https://github.com/imagemin/optipng-bin/issues/84 | ||
RUN apk --no-cache add pkgconfig autoconf automake libtool nasm build-base zlib-dev | ||
|
||
# make the 'client' folder the current working directory | ||
WORKDIR /client | ||
|
||
# copy both 'package.json' and 'package-lock.json' (if available) | ||
COPY ./client/package*.json ./ | ||
COPY ./client/ ./ | ||
|
||
# install project dependencies | ||
RUN yarn install | ||
RUN yarn global add @quasar/cli | ||
RUN quasar upgrade -i | ||
|
||
# copy project files and folders to the current working directory (i.e. 'app' folder) | ||
COPY ./client ./ | ||
|
||
# build app for production with minification use build-cloud or build-da | ||
# RUN yarn run build-dev | ||
RUN yarn run build-da | ||
# RUN yarn run build-cloud | ||
# RUN ls -la ./ | ||
# RUN ls -la ./dist | ||
# RUN chmod -R ug+rw ./dist | ||
|
||
# EXPOSE 8080 | ||
# CMD [ "http-server", "dist" ] | ||
|
||
##################################### | ||
# Final stage: the running container. | ||
# FROM scratch AS final | ||
FROM alpine AS final | ||
|
||
# Import the user and group files from the first stage. | ||
COPY --from=backend /user/group /user/passwd /etc/ | ||
|
||
# Import the Certificate-Authority certificates for enabling HTTPS. | ||
COPY --from=backend /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
|
||
# Import the compiled executable from the first stage. | ||
COPY --from=backend /timesheet.bin /timesheet.bin | ||
# Copy data folder | ||
COPY --from=backend /data /data | ||
# Copy documentation folder | ||
COPY --from=backend /documentation /documentation | ||
# Copy log folder | ||
COPY --from=backend /logs /logs | ||
# Copy compiled frontend files | ||
COPY --from=frontend /client/dist/spa /client/dist | ||
|
||
# Declare the port on which the webbackend will be exposed. | ||
# As we're going to run the executable as an unprivileged user, we can't bind | ||
# to ports below 1024. | ||
# Expose is NOT supported by Heroku | ||
# EXPOSE 3000 | ||
|
||
# Perform any further action as an unprivileged user. | ||
# USER nobody:nobody | ||
|
||
COPY --from=backend /docker-entrypoint.sh /docker-entrypoint.sh | ||
COPY --from=backend /timesheet.yaml /timesheet.yaml | ||
# Run the compiled binary. | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
CMD ["/docker-entrypoint.sh --debug=5"] |
Oops, something went wrong.