Merge pull request #1 from PretendoNetwork/docker

This commit is contained in:
Jonathan Barrow 2023-07-12 02:23:14 -04:00 committed by GitHub
commit b8be11bedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
.env
.git
build
log
go.work
*.test
go.work.sum

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
# --- builder ---
FROM golang:1.20.6-alpine3.17 as builder
LABEL stage=builder
RUN apk add git
WORKDIR /build
COPY go.* ./
RUN go mod download
COPY . ./
ARG BUILD_STRING=pretendo.pikmin3.docker
RUN go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o server
# --- runner ---
FROM alpine:3.17 as runner
WORKDIR /build
COPY --from=builder /build/server /build/
CMD ["/build/server"]

View File

@ -11,6 +11,33 @@ $ git clone https://github.com/PretendoNetwork/pikmin-3
$ cd pikmin-3
```
### Compiling and running using `docker` (PREFERRED)
Make sure you have Docker installed on your system. This can be done using various instructions available online.
Once installed, execute the following to build:
```bash
$ docker build -t pikmin3 --build-arg BUILD_STRING=YOUR_BUILD_STRING_HERE .
$ docker image prune --filter label=stage=builder -f
```
Note: `--build-arg` flag/variable is optional.
Create a `.env` file with all of the necessary environment variables set. The variable list is available below.
Example:
```
PN_PIKMIN3_POSTGRES_URI=postgres://username:password@localhost/pikmin3?sslmode=disable
PN_PIKMIN3_AUTHENTICATION_SERVER_PORT=61001
...
```
Then, you can use the following command to run the image.
```bash
$ docker run --name pikmin3 --env-file .env -it pikmin3
```
Other tools and systems can also make use of this image, including Docker Compose and Portainer.
### Compiling using `go`
To compile using Go, `go get` the required modules and then `go build` to your desired location. You may also want to tidy the go modules, though this is optional