Add Dockerfile

This commit is contained in:
Maciej Krzyżanowski 2024-06-21 15:06:20 +02:00
parent 84193ed322
commit 05a4063ef3
2 changed files with 29 additions and 0 deletions

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM golang:1.22 AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY *.go .
COPY common/ common/
COPY client/ client/
COPY server/ server/
RUN go build -v -o ./archat-server .
FROM ubuntu:noble
WORKDIR /app
COPY --from=build /app/archat-server /app/archat-server
CMD ["./archat-server", "--run", "server"]

View File

@ -23,3 +23,18 @@ go run . --run server --waddr krzyzanowski.dev:8080 --uaddr krzyzanowski.dev:808
`--waddr` and `--uaddr` options are optional, default values are respectively `:8080` and `:8081` (which is a short form of `localhost:8080` and `localhost:8081`) `--waddr` and `--uaddr` options are optional, default values are respectively `:8080` and `:8081` (which is a short form of `localhost:8080` and `localhost:8081`)
`--run` option is mandatory and may take value of either `client` or `server` `--run` option is mandatory and may take value of either `client` or `server`
## Running using Docker
You are provided with Dockerfile inside this repository. You can use it to build your image and run archat-server
in a container. This image does not allow to run client, because it does not make sense.
0. Enter the top directory of this repository (using cd)
1. Start with building image
```bash
docker build -t archat-server .
```
2. Now run a container
```bash
docker run -d -p 8080-8081:8080-8081 archat-server
```
You may change exposed ports according to your needs, just remember that they need to be open. Also, be sure to build an image after any code update :)