Compare commits
No commits in common. "3edd9bd1ca33b0635a79cb080d10dca6d28a5327" and "38666239cf5e53d459ece5d8f1a262ca7ecec700" have entirely different histories.
3edd9bd1ca
...
38666239cf
|
@ -1,4 +0,0 @@
|
||||||
# .dockerignore
|
|
||||||
.git
|
|
||||||
README.md
|
|
||||||
LICENSE
|
|
2
.env
2
.env
|
@ -1,2 +0,0 @@
|
||||||
# Change this to --vegan if you want a vegan potato
|
|
||||||
VEGAN="--nonvegan"
|
|
|
@ -1,27 +0,0 @@
|
||||||
########### Phase 1 - Compile ###########
|
|
||||||
FROM maven:3.9.8-eclipse-temurin-8-alpine AS potato-builder
|
|
||||||
|
|
||||||
# Set the working directory and copy src
|
|
||||||
WORKDIR /usr/src/Potato
|
|
||||||
COPY . /usr/src/Potato/
|
|
||||||
|
|
||||||
# Build with Maven
|
|
||||||
RUN mvn clean install;
|
|
||||||
|
|
||||||
########### Phase 2 - Package ###########
|
|
||||||
FROM eclipse-temurin:21
|
|
||||||
|
|
||||||
# Can be overridden with `docker run -e VEGAN="--vegan"`
|
|
||||||
ENV VEGAN=""
|
|
||||||
|
|
||||||
# Make am appropriate user name
|
|
||||||
RUN useradd -u 500 mrpotatohead
|
|
||||||
USER mrpotatohead
|
|
||||||
|
|
||||||
WORKDIR /home/mrpotatohead
|
|
||||||
|
|
||||||
# Cook this potato right every time
|
|
||||||
COPY --from=potato-builder /usr/src/Potato/target /home/mrpotatohead/target
|
|
||||||
|
|
||||||
# Allow user to pass in an argument when running the container
|
|
||||||
CMD ["sh","-c","java -jar target/Potato.jar ${VEGAN}"]
|
|
|
@ -1,24 +0,0 @@
|
||||||
# HOW TO BUILD & RUN THE POTATO IMAGE
|
|
||||||
# 1. Run the potato-build.sh script and pass in an optional tag for the container
|
|
||||||
# e.g. ./potato-build.sh 1.0.0
|
|
||||||
# 1a. Run the potato-run.sh script and pass in an optional prepare type argument
|
|
||||||
# e.g. ./potato-run.sh "--vegan"
|
|
||||||
# 2. You can run using docker compose run
|
|
||||||
# e.g. docker compose run --build potato (Builds image before running)
|
|
||||||
# e.g. docker compose run potato (if you already built it)
|
|
||||||
# e.g. docker compose run potato --rm (removes the container upon exit)
|
|
||||||
# 2a. To pass in an argument, either edit the .env file,
|
|
||||||
# or set a local environment variable: e.g. export VEGAN="--vegan"
|
|
||||||
# 3. You can run using docker compose up.
|
|
||||||
# e.g. docker compose up
|
|
||||||
# 3a. Make sure to clean up containers since compose up doesn't have a --rm option
|
|
||||||
# e.g. docker container rm potato-potato-1
|
|
||||||
|
|
||||||
services:
|
|
||||||
potato:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./Dockerfile.spud
|
|
||||||
environment:
|
|
||||||
- VEGAN=${VEGAN}
|
|
||||||
|
|
10
pom.xml
10
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.drtshock</groupId>
|
<groupId>org.drtshock</groupId>
|
||||||
<artifactId>potato</artifactId>
|
<artifactId>potato</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>1.7.5</version>
|
||||||
<name>Potato</name>
|
<name>Potato</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.12.1</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.0.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<addMavenDescriptor>false</addMavenDescriptor>
|
<addMavenDescriptor>false</addMavenDescriptor>
|
||||||
|
@ -34,12 +34,12 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.0.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.orfjackal.retrolambda</groupId>
|
<groupId>net.orfjackal.retrolambda</groupId>
|
||||||
<artifactId>retrolambda-maven-plugin</artifactId>
|
<artifactId>retrolambda-maven-plugin</artifactId>
|
||||||
<version>2.5.7</version>
|
<version>2.5.3</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# HOW TO BUILD THE POTATO IMAGE
|
|
||||||
# 1. Run this script and pass in an optional tag for the container
|
|
||||||
# e.g. ./potato-build.sh 1.0.0
|
|
||||||
# 2. Alternatively, you can can run using docker compose
|
|
||||||
# e.g. docker compose run --build potato
|
|
||||||
# 2a. To pass in an argument, either edit the .env file,
|
|
||||||
# or set a local environment variable: e.g. export VEGAN="--vegan"
|
|
||||||
|
|
||||||
# Tag for the built container
|
|
||||||
TAG=latest
|
|
||||||
|
|
||||||
if ! [ -z $1 ]; then
|
|
||||||
if [[ $1 == "-h" || $1 == "?" ]]; then
|
|
||||||
# Print usage
|
|
||||||
echo "Usage: $0 <tag>"
|
|
||||||
echo "Example: $0 1.0.0"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
TAG=$1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if Docker is installed
|
|
||||||
if ! [ -x "$(command -v docker)" ]; then
|
|
||||||
echo "You need to install Docker."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Using tag: '$TAG'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Perform the build
|
|
||||||
docker build -t potato:$TAG -f Dockerfile.spud .
|
|
|
@ -1,40 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# HOW TO RUN THE POTATO IMAGE
|
|
||||||
# 1. Run this script and pass in an optional prepare type argument
|
|
||||||
# e.g. ./potato-run.sh "--vegan"
|
|
||||||
# 2. You can run using docker compose run
|
|
||||||
# e.g. docker compose run --build potato (builds the container before running)
|
|
||||||
# e.g. docker compose run potato (if you already built it)
|
|
||||||
# e.g. docker compose run potato --rm (removes the container upon exit)
|
|
||||||
# 2a. To pass in an argument, either edit the .env file,
|
|
||||||
# or set a local environment variable: e.g. export VEGAN="--vegan"
|
|
||||||
# 3. You can run using docker compose up and passing in the --build arg
|
|
||||||
# e.g. docker compose up --build
|
|
||||||
# 3a. Make sure to clean up containers since compose up doesn't have a --rm option
|
|
||||||
# e.g. docker container rm potato-potato-1
|
|
||||||
|
|
||||||
|
|
||||||
# Preparation type for the built potato container
|
|
||||||
PREPARE_TYPE="--nonvegan"
|
|
||||||
|
|
||||||
if ! [ -z $1 ]; then
|
|
||||||
if [[ $1 == "-h" || $1 == "?" ]]; then
|
|
||||||
# Print usage
|
|
||||||
echo "Usage: $0 <prepare type>"
|
|
||||||
echo "Example: $0 --vegan"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
PREPARE_TYPE=$1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Check if Docker is installed
|
|
||||||
if ! [ -x "$(command -v docker)" ]; then
|
|
||||||
echo "You need to install Docker."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Running Potato with argument: \"$PREPARE_TYPE\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Perform the build
|
|
||||||
docker run -it --name potato-in-a-container --rm -e VEGAN=${PREPARE_TYPE} potato:latest
|
|
|
@ -88,7 +88,7 @@ public class Potato implements Tuber {
|
||||||
final URL url = new URL("https://www.google.com/search?q=potato");
|
final URL url = new URL("https://www.google.com/search?q=potato");
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
connection.addRequestProperty("User-Agent", "Potato/2.0.0");
|
connection.addRequestProperty("User-Agent", "Potato/1.7.5");
|
||||||
connection.connect();
|
connection.connect();
|
||||||
int inOven = connection.getResponseCode();
|
int inOven = connection.getResponseCode();
|
||||||
long bakeTime = (System.currentTimeMillis() - begin);
|
long bakeTime = (System.currentTimeMillis() - begin);
|
||||||
|
|
Loading…
Reference in New Issue