diff --git a/result/Dockerfile b/result/Dockerfile index 5659724..a3e7761 100644 --- a/result/Dockerfile +++ b/result/Dockerfile @@ -1,28 +1,19 @@ # Shared base -FROM node:18-slim AS base +FROM node:18-alpine WORKDIR /app -COPY package*.json ./ +COPY . . + +RUN npm config set registry https://registry.npmjs.org \ + && npm install -g nodemon -RUN npm ci \ +RUN npm install \ && npm cache clean --force \ && mv /app/node_modules /node_modules -COPY . . - -ENV PORT 80 +ENV PORT=80 EXPOSE 80 CMD ["node", "server.js"] - -# Development -FROM base as dev - -RUN npm install -g nodemon - -# Production -FROM base - -RUN npm install -g nodemon diff --git a/result/README.md b/result/README.md new file mode 100644 index 0000000..630db01 --- /dev/null +++ b/result/README.md @@ -0,0 +1,14 @@ +| **Sub-heading** | **Instruction / Value** | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **Base Image** | node:18-alpine | +| **Work Directory** | /app | +| **Port** | 80 | +| **Launch Command** | node server.js | +| **Build Instruction** | npm config set registry [https://registry.npmjs.org](https://registry.npmjs.org) + npm install -g nodemon + + npm install \ +
&& npm ls \ +
&& npm cache clean --force \ +
&& mv /app/node_modules /node_modules + diff --git a/vote/Dockerfile b/vote/Dockerfile index 6530841..e05882c 100644 --- a/vote/Dockerfile +++ b/vote/Dockerfile @@ -1,18 +1,15 @@ -# Using official python runtime base image -FROM python:3.11-alpine +FROM python:2.7-alpine -# Set the application directory WORKDIR /app -# Install our requirements.txt -ADD requirements.txt /app/requirements.txt -RUN pip install -r requirements.txt +# Copy application files +COPY . . -# Copy our code from the current folder to /app inside the container -ADD . /app +# Install dependencies +RUN pip install -r requirements.txt -# Make port 80 available for links and/or publish +# Expose application port EXPOSE 80 -# Define our command to be run when launching the container -CMD ["gunicorn", "app:app", "-b", "0.0.0.0:80", "--log-file", "-", "--access-logfile", "-", "--workers", "4", "--keep-alive", "0"] +# Start the app +CMD ["gunicorn", "app:app", "-b", "0.0.0.0:80"] diff --git a/vote/README.md b/vote/README.md new file mode 100644 index 0000000..90800e8 --- /dev/null +++ b/vote/README.md @@ -0,0 +1,8 @@ +Item Description +Base python:2.7-alpine +Work Directory /app +Build Instruction pip install -r requirement.txt +port 80 +launch command gunicorn app:app -b 0.0.0.0:80 + + diff --git a/worker/Dockerfile b/worker/Dockerfile index 5b29cd1..560ca07 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -1,17 +1,9 @@ -FROM maven:3.9-amazoncorretto-8 AS build - +FROM joshua122/worker:v2 AS build WORKDIR /code +COPY . . +RUN mvn package -Dskiptests -COPY pom.xml /code/pom.xml -RUN ["mvn", "dependency:resolve"] -RUN ["mvn", "verify"] - -# Adding source, compile and package into a fat jar -COPY ["src/main", "/code/src/main"] -RUN ["mvn", "package"] - -FROM amazoncorretto:8-alpine-jre - -COPY --from=build /code/target/worker-jar-with-dependencies.jar / - -CMD ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-jar", "/worker-jar-with-dependencies.jar"] +FROM openjdk:8-jre-alpine +WORKDIR /run +COPY --from=build /code/target/worker-jar-with-dependencies.jar worker.jar +CMD ["java", "-jar", "worker.jar"] diff --git a/worker/Dockerfile.base b/worker/Dockerfile.base new file mode 100644 index 0000000..33860d9 --- /dev/null +++ b/worker/Dockerfile.base @@ -0,0 +1,4 @@ +FROM maven:3.5-jdk-8-alpine AS build +WORKDIR /code +COPY pom.xml ./ +RUN mvn dependency:go-offline diff --git a/worker/READme.md b/worker/READme.md new file mode 100644 index 0000000..86bd673 --- /dev/null +++ b/worker/READme.md @@ -0,0 +1,11 @@ + image build information : + +| **Item** | **Description** | +| --------------------- | ---------------------------------------------- | +| **Base** | `maven:3.5-jdk-8-alpine` | +| **Work directory** | `/code` | +| **Build instruction** | `mvn package -D skiptests` | +| **Ports** | N/A | +| **Runtime image** | `openjdk:8-jre-alpine` | +| **Launch command** | `java -jar target/worker-jar-dependencies.jar` | +