Skip to content

Commit

Permalink
Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed Oct 12, 2021
1 parent 5062841 commit ed53fa6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# bytebin Dockerfile
# Copyright (c) lucko - licenced MIT

# --------------
# BUILD STAGE
# --------------
FROM eclipse-temurin:17-alpine as build

# for objcopy, needed by jlink
RUN apk add binutils

# create a minimal JRE
RUN $JAVA_HOME/bin/jlink \
--add-modules java.base,java.logging,java.xml,java.desktop,java.management,java.sql,java.naming,jdk.unsupported \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /jre

# install maven
RUN apk add maven

# compile the project
COPY . /bytebin/
WORKDIR /bytebin
RUN mvn clean package


# --------------
# RUN STAGE
# --------------
FROM alpine

# copy JRE from build stage
ENV JAVA_HOME=/opt/java
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=build /jre $JAVA_HOME

# copy app from build stage
COPY --from=build /bytebin/target/bytebin.jar /opt/bytebin/

# define a simple healthcheck
HEALTHCHECK --interval=1m --timeout=3s \
CMD wget http://localhost:8080/ -q -O - > /dev/null 2>&1 || exit 1

# run the app
WORKDIR /opt/bytebin
CMD ["java", "-jar", "bytebin.jar"]
EXPOSE 8080/tcp
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@ I host a [public instance](#public-instances) of bytebin for some of my own proj

There is also a traditional "pastebin" frontend for sharing code/configs/whatever, see [lucko/paste](https://github.com/lucko/paste) for more information.

## API usage
## Hosting

The easiest way to spin up a bytebin instance is using Docker.

Create an image from the `Dockerfile`:
```bash
$ docker build -t bytebin .
```

Start a container:
```bash
$ docker run -dp 3000:8080 bytebin
```

You can then access the application at `http://localhost:3000/`.


## API Usage

### Read

Expand Down

0 comments on commit ed53fa6

Please sign in to comment.