Skip to content

Commit

Permalink
updated docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanpoland committed Jul 28, 2024
1 parent dfe8e88 commit 766a1f8
Show file tree
Hide file tree
Showing 7 changed files with 4,046 additions and 124 deletions.
36 changes: 34 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,40 @@
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/<executable file>",
"name": "Debug executable 'example'",
"cargo": {
"args": [
"build",
"--bin=example",
"--package=example"
],
"filter": {
"name": "example",
"kind": "bin"
}
},
"args": [
// "user_arg1",
// "user_arg2"
],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'example'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=example",
"--package=example"
],
"filter": {
"name": "example",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
Expand Down
33 changes: 21 additions & 12 deletions Dockerfile.rust → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ ARG APP_NAME
WORKDIR /app

# Install host build dependencies.
RUN apk add libressl-dev
RUN apk add --no-cache clang lld musl-dev git pkgconfig
RUN apk add libressl-dev clang clang-dev sqlite-dev go \
apk add --no-cache clang lld musl-dev git pkgconfig \
apk add --no-cache curl xz && \
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.0/clang+llvm-17.0.0-x86_64-linux-gnu.tar.xz && \
tar -xf clang+llvm-17.0.0-x86_64-linux-gnu.tar.xz && \
mv clang+llvm-17.0.0-x86_64-linux-gnu /usr/local/clang && \
rm clang+llvm-17.0.0-x86_64-linux-gnu.tar.xz && \
echo 'export PATH=/usr/local/clang/bin:$PATH' >> /etc/profile.d/clang.sh

# Build the application.
# Leverage a cache mount to /usr/local/cargo/registry/
Expand All @@ -28,14 +34,16 @@ RUN apk add --no-cache clang lld musl-dev git pkgconfig
# Leverage a bind mount to the src directory to avoid having to copy the
# source code into the container. Once built, copy the executable to an
# output directory before the cache mounted /app/target is unmounted.
RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --locked --release && \
cp ./target/release/$APP_NAME /bin/server

# RUN --mount=type=bind,source=src,target=src \
# --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
# --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
# --mount=type=cache,target=/app/target/ \
# --mount=type=cache,target=/usr/local/cargo/git/db \
# --mount=type=cache,target=/usr/local/cargo/registry/ \
# cargo build --locked --release && \
# cp ./target/release/$APP_NAME /bin/server


################################################################################
# Create a new stage for running the application that contains the minimal
Expand Down Expand Up @@ -63,10 +71,11 @@ RUN adduser \
USER appuser

# Copy the executable from the "build" stage.
COPY --from=build /bin/server /bin/

# COPY --from=build /bin/server /bin/

# Expose the port that the application listens on.
EXPOSE 3000

# What the container should run when it is started.
CMD ["/bin/server"]
CMD ["tail","-f","/dev/null"]
15 changes: 0 additions & 15 deletions Dockerfile.golang

This file was deleted.

63 changes: 0 additions & 63 deletions Dockerfile.python

This file was deleted.

33 changes: 1 addition & 32 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
horizon-game-server:
build:
context: .
dockerfile: Dockerfile.rust
dockerfile: Dockerfile
ports:
- "3000:3000"
- "3001:3001"
Expand All @@ -11,37 +11,6 @@ services:
networks:
- horizon-network

horizon-memory-db:
build:
context: .
dockerfile: Dockerfile.golang
restart: always
depends_on:
- horizon-game-server
ports:
- "3003:3003"
environment:
- DB_USER=admin
- DB_PASSWORD=secret
volumes:
- memory-db-data:/var/lib/horizon-memory-db
networks:
- horizon-network

horizon-physics-engine:
build:
context: .
dockerfile: Dockerfile.python
restart: always
depends_on:
- horizon-memory-db
ports:
- "3002:3002"
environment:
- PYTHONUNBUFFERED=1
networks:
- horizon-network

volumes:
memory-db-data:

Expand Down
Loading

0 comments on commit 766a1f8

Please sign in to comment.