Skip to content

Commit

Permalink
Merge pull request #23 from rishkwal/rishkwal/linux-docker-setup
Browse files Browse the repository at this point in the history
feat: optimize docker for linux
  • Loading branch information
rishkwal authored Jul 17, 2024
2 parents 3d651eb + 2961623 commit 500e0da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
16 changes: 4 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
FROM debian:bullseye-slim

ARG UID=1000
ARG GID=1000
ENV BITCOIN_VERSION=27.0
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
ENV PATH=/opt/bitcoin-${BITCOIN_VERSION}/bin:$PATH

# Install dependencies and create bitcoin user
RUN apt-get update && apt-get install -y curl gnupg gosu \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& groupadd -g ${GID} bitcoin \
&& useradd -u ${UID} -g bitcoin -s /bin/bash -m -d /home/bitcoin bitcoin
# Install dependencies
RUN apt-get update && apt-get install -y curl gnupg \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Download and install Bitcoin Core
ARG TARGETPLATFORM
Expand All @@ -28,14 +23,11 @@ RUN set -ex \
# Copy Bitcoin configuration
COPY bitcoin.conf /etc/bitcoin.conf

VOLUME ["/home/bitcoin/.bitcoin"]
RUN mkdir -p /root/.bitcoin
EXPOSE 18443 18444

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

USER bitcoin
WORKDIR /home/bitcoin

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bitcoind", "-regtest"]
5 changes: 1 addition & 4 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/bash
set -e

cp /etc/bitcoin.conf "$BITCOIN_DATA/bitcoin.conf"
chown -R bitcoin:bitcoin ${BITCOIN_DATA} \
&& chmod 755 ${BITCOIN_DATA} \
&& chmod 600 ${BITCOIN_DATA}/bitcoin.conf
cp /etc/bitcoin.conf /root/.bitcoin/bitcoin.conf \

exec "$@"
4 changes: 2 additions & 2 deletions src/bin/bitbrew.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node --no-warnings
#!/usr/bin/env -S node --no-warnings
import { Command } from 'commander';
import figlet from 'figlet';
import chalk from 'chalk';
Expand Down Expand Up @@ -44,12 +44,12 @@ program.addCommand(LsCommand);
program.addCommand(StartCommand);
program.addCommand(StopCommand);
program.addCommand(AddCommand);
program.addCommand(CleanCommand);
program.addCommand(RemoveCommand);
program.addCommand(ExecCommand);
program.addCommand(AttachCommand);
program.addCommand(WalletCommand);
program.addCommand(SendCommand);
program.addCommand(MineCommand);
program.addCommand(CleanCommand);

program.parse(process.argv);
6 changes: 3 additions & 3 deletions src/controllers/nodeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class NodeController {
fs.mkdirSync(node.dataDir, { recursive: true });
}

const imageName = `rishkwal/bitbrew-bitcoin-core:27.0-0.1.0-alpha`;
const imageName = `rishkwal/bitbrew-bitcoind:27.0-0.1.0-alpha`;
let images = await this.dockerController.docker.listImages({
filters: { reference: [imageName] },
});
Expand Down Expand Up @@ -81,8 +81,8 @@ export class NodeController {
},
HostConfig: {
Binds: [
`${node.dataDir}:/home/bitcoin/.bitcoin`,
`${this.stateController.getWalletsDir()}:/home/bitcoin/.bitcoin/regtest/wallets`,
`${node.dataDir}:/root/.bitcoin`,
`${this.stateController.getWalletsDir()}:/root/.bitcoin/regtest/wallets`,
],
PortBindings: {
'18444/tcp': [{ HostPort: node.hostPort.toString() }],
Expand Down

0 comments on commit 500e0da

Please sign in to comment.