Skip to content

Commit

Permalink
Merge pull request #2169 from bakdata/feature/small-docker-images
Browse files Browse the repository at this point in the history
Feature/small docker images
  • Loading branch information
thoniTUB authored Nov 1, 2021
2 parents e0f5c9f + 9fc1dc3 commit 1da5864
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM maven:3.8-openjdk-11-slim AS builder

COPY . /app


WORKDIR /app
RUN ./build_version.sh


FROM openjdk:11.0.12-slim AS runner

WORKDIR /app
COPY --from=builder /app/executable/target/executable*jar ./conquery.jar

ENV CLUSTER_PORT=${CLUSTER_PORT:-8082}
ENV ADMIN_PORT=${ADMIN_PORT:-8081}
ENV API_PORT=${API_PORT:-8080}

ENTRYPOINT [ "java", "-jar", "conquery.jar" ]

CMD [ "standalone" ]

EXPOSE $CLUSTER_PORT $ADMIN_PORT $API_PORT

2 changes: 1 addition & 1 deletion build_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

mvn clean initialize -P setVersion

mvn -T 1C package -DskipTests -pl executable -am
mvn -T 1C package -Dmaven.test.skip=true -DskipTests -pl executable -am
23 changes: 16 additions & 7 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
FROM mhart/alpine-node:16
RUN apk add --no-cache bash
FROM mhart/alpine-node:16 AS builder

RUN mkdir /conquery
WORKDIR /conquery
WORKDIR /app
COPY ./package.json .

COPY ./package.json ./yarn.lock ./
RUN yarn --no-progress --frozen-lockfile

COPY . .

# Uses env variables from .env file (BUILD TIME)
RUN PUBLIC_URL=/ yarn build

# The final image is just an nginx with a webroot
FROM nginx:stable-alpine

# To allow passing env variables at RUN TIME
# we're injecting them into the built artifacts.
# See `./scripts/replace-env-at-runtime.sh`, `.env`, `.env.example` for details
Expand All @@ -24,6 +25,14 @@ ENV REACT_APP_IDP_URL=$REACT_APP_IDP_URL
ENV REACT_APP_IDP_REALM=$REACT_APP_IDP_REALM
ENV REACT_APP_IDP_CLIENT_ID=$REACT_APP_IDP_CLIENT_ID

CMD /bin/bash ./scripts/replace-env-at-runtime.sh && PORT=8000 NODE_ENV=production node server
# Copy the build artifacts from the builder phase
COPY --from=builder /app/build /usr/share/nginx/html
# Copy the env replacer
COPY ./scripts/replace-env-at-runtime.sh /

# The default command replaces the environment variables and starts nginx as a subprocess
CMD [ "/bin/sh", "-c", "/replace-env-at-runtime.sh /usr/share/nginx/html/index.html && nginx -g \"daemon off;\""]


EXPOSE 80

EXPOSE 8000

0 comments on commit 1da5864

Please sign in to comment.